Skip to content

Commit

Permalink
Use gradle-nexus-plugin for publishing to Sonatype
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasMikula committed Apr 3, 2015
1 parent cd87a0f commit c050c24
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 76 deletions.
86 changes: 12 additions & 74 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ version = '0.2-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.7.1'
}
}

repositories {
mavenCentral()
}

apply from: 'gradle/publish.gradle'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

Expand All @@ -22,75 +32,3 @@ javadoc {
// ignore missing Javadoc comments or tags
options.addStringOption('Xdoclint:all,-missing', '-quiet')
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives jar

archives javadocJar
archives sourcesJar
}

signing {
sign configurations.archives
}

signArchives.onlyIf {
project.hasProperty('signing.keyId') && project.hasProperty('signing.password') && project.hasProperty('signing.secretKeyRingFile')
}

def doUploadArchives = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')

if(doUploadArchives) {
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

pom.project {
name 'WellBehavedFX'
packaging 'jar'
description 'Composable event handlers and skin skeletons for JavaFX controls.'
url 'http://www.fxmisc.org/wellbehaved/'

scm {
url 'scm:git@github.com:TomasMikula/WellBehavedFX.git'
connection 'scm:git@github.com:TomasMikula/WellBehavedFX.git'
developerConnection 'scm:git@github.com:TomasMikula/WellBehavedFX.git'
}

licenses {
license {
name 'The BSD 2-Clause License'
url 'http://opensource.org/licenses/BSD-2-Clause'
distribution 'repo'
}
}

developers {
developer {
name 'Tomas Mikula'
}
}
}
}
}
}

uploadArchives.onlyIf { doUploadArchives }
4 changes: 2 additions & 2 deletions gradle.properties.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sonatypeUsername = <username>
sonatypePassword = <password>
nexusUsername = <username>
nexusPassword = <password>

signing.keyId = <key id>
signing.password = <key passphrase>
Expand Down
32 changes: 32 additions & 0 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apply plugin: 'nexus'

modifyPom {
project {
name 'WellBehavedFX'
description 'Composable event handlers and skin skeletons for JavaFX controls.'
url 'http://www.fxmisc.org/wellbehaved/'
packaging 'jar'
licenses {
license {
name 'The BSD 2-Clause License'
url 'http://opensource.org/licenses/BSD-2-Clause'
distribution 'repo'
}
}
scm {
url 'scm:git@github.com:TomasMikula/WellBehavedFX.git'
connection 'scm:git@github.com:TomasMikula/WellBehavedFX.git'
developerConnection 'scm:git@github.com:TomasMikula/WellBehavedFX.git'
}
developers {
developer {
name 'Tomas Mikula'
}
}
}
}

nexus {
repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
}

0 comments on commit c050c24

Please sign in to comment.