Skip to content

Commit 75e7d56

Browse files
committed
Finished configuration for maven central upload
1 parent 3bad070 commit 75e7d56

File tree

1 file changed

+65
-30
lines changed

1 file changed

+65
-30
lines changed

build.gradle

Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ allprojects {
3131
}
3232
}
3333

34-
35-
36-
3734
task javadocJar(type: Jar, dependsOn: javadoc) {
3835
classifier = "javadoc"
3936
from "build/docs/javadoc"
@@ -52,44 +49,81 @@ artifacts {
5249
archives sourcesJar
5350
}
5451

55-
signing {
56-
sign configurations.archives
52+
def sonatypeRepositoryUrl
53+
54+
def isDevBuild
55+
def isSnapshotBuild
56+
def isReleaseBuild
57+
58+
59+
60+
// release with 'gradle uploadArchives -Prelease'
61+
// release snapshot with 'gradle uploadArchives -Psnapshot'
62+
if (hasProperty("release")) {
63+
println "release"
64+
isReleaseBuild = true
65+
sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
66+
} else if (hasProperty("snapshot")) {
67+
println "snapshot"
68+
isSnapshotBuild = true
69+
version += "-SNAPSHOT"
70+
sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
71+
} else {
72+
println "dev build"
73+
isDevBuild = true
74+
}
75+
76+
//********* artifact signing *********
77+
if (isReleaseBuild) {
78+
signing {
79+
sign configurations.archives
80+
}
81+
} else {
82+
task signArchives {
83+
// do nothing
84+
}
5785
}
5886

5987

6088
uploadArchives {
6189
repositories {
62-
mavenDeployer {
63-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
90+
if (isDevBuild) {
91+
mavenLocal()
92+
} else {
93+
mavenDeployer {
94+
if(isReleaseBuild) {
95+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
96+
}
6497

65-
repository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
66-
authentication(userName: sonatypeUsername, password: sonatypePassword)
67-
}
98+
repository(url: sonatypeRepositoryUrl) {
99+
authentication(userName: sonatypeUsername, password: sonatypePassword)
100+
}
68101

69-
pom.project {
70-
name = "assertj-javafx"
71-
packaging = "jar"
72-
description "AssertJ-JavaFX is a package of assertj assertions for JavaFX"
73-
url "https://github.com/lestard/assertj-javafx"
102+
pom.project {
103+
name = "assertj-javafx"
104+
packaging = "jar"
105+
description "AssertJ-JavaFX is a package of assertj assertions for JavaFX"
106+
url "https://github.com/lestard/assertj-javafx"
74107

75-
scm {
76-
url "scm:git@github.com:lestard/assertj-javafx.git"
77-
connection "scm:git@github.com:lestard/assertj-javafx.git"
78-
developerConnection "scm:git@github.com:lestard/assertj-javafx.git"
79-
}
108+
scm {
109+
url "scm:git@github.com:lestard/assertj-javafx.git"
110+
connection "scm:git@github.com:lestard/assertj-javafx.git"
111+
developerConnection "scm:git@github.com:lestard/assertj-javafx.git"
112+
}
80113

81-
licenses {
82-
license {
83-
name 'The Apache Software License, Version 2.0'
84-
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
85-
distribution 'repo'
114+
licenses {
115+
license {
116+
name 'The Apache Software License, Version 2.0'
117+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
118+
distribution 'repo'
119+
}
86120
}
87-
}
88121

89-
developers {
90-
developer {
91-
id "manuel.mauky"
92-
name "Manuel Mauky"
122+
developers {
123+
developer {
124+
id "manuel.mauky"
125+
name "Manuel Mauky"
126+
}
93127
}
94128
}
95129
}
@@ -98,6 +132,7 @@ uploadArchives {
98132
}
99133

100134
import org.gradle.plugins.signing.Sign
135+
101136
gradle.taskGraph.whenReady { taskGraph ->
102137
if (taskGraph.allTasks.any { it instanceof Sign }) {
103138
// Use Java 6's console to read from the console (no good for a CI environment)

0 commit comments

Comments
 (0)