@@ -5,11 +5,9 @@ plugins {
55 id ' nebula.optional-base' version ' 3.2.0'
66 id ' com.github.hierynomus.license' version ' 0.15.0'
77 id ' com.github.spotbugs' version " 4.5.0"
8- id " com.jfrog.bintray" version " 1.8.5"
98}
109
1110allprojects {
12- group = ' com.optimizely.ab'
1311 apply plugin : ' idea'
1412 apply plugin : ' jacoco'
1513
@@ -22,26 +20,27 @@ allprojects {
2220 }
2321}
2422
25- apply from : ' gradle/publish.gradle'
26-
2723allprojects {
24+ group = ' com.optimizely.ab'
25+
2826 def travis_defined_version = System . getenv(' TRAVIS_TAG' )
2927 if (travis_defined_version != null ) {
3028 version = travis_defined_version
3129 }
3230}
3331
34- subprojects {
35- apply plugin : ' com.jfrog.bintray'
32+ def publishedProjects = subprojects. findAll { it. name != ' java-quickstart' }
33+
34+ configure(publishedProjects) {
3635 apply plugin : ' com.github.spotbugs'
3736 apply plugin : ' jacoco'
3837 apply plugin : ' java'
3938 apply plugin : ' maven-publish'
39+ apply plugin : ' signing'
4040 apply plugin : ' me.champeau.gradle.jmh'
4141 apply plugin : ' nebula.optional-base'
4242 apply plugin : ' com.github.hierynomus.license'
4343
44-
4544 sourceCompatibility = 1.8
4645 targetCompatibility = 1.8
4746
@@ -62,11 +61,6 @@ subprojects {
6261 from javadoc. destinationDir
6362 }
6463
65- artifacts {
66- archives sourcesJar
67- archives javadocJar
68- }
69-
7064 spotbugsMain {
7165 reports {
7266 xml. enabled = false
@@ -115,34 +109,42 @@ subprojects {
115109 testCompile group : ' com.fasterxml.jackson.core' , name : ' jackson-databind' , version : jacksonVersion
116110 }
117111
118- publishing {
119- publications {
120- mavenJava(MavenPublication ) {
121- from components. java
122- artifact sourcesJar
123- artifact javadocJar
124- pom. withXml {
125- asNode(). children(). last() + {
126- resolveStrategy = Closure . DELEGATE_FIRST
127- url ' https://github.com/optimizely/java-sdk'
128- licenses {
129- license {
130- name ' The Apache Software License, Version 2.0'
131- url ' http://www.apache.org/license/LICENSE-2.0.txt'
132- distribution ' repo'
133- }
134- }
135- developers {
136- developer {
137- id ' optimizely'
138- name ' Optimizely'
139- 140- }
141- }
112+ def docTitle = " Optimizely Java SDK"
113+ if (name. equals(' core-httpclient-impl' )) {
114+ docTitle = " Optimizely Java SDK: Httpclient"
115+ }
116+
117+ afterEvaluate {
118+ publishing {
119+ publications {
120+ release(MavenPublication ) {
121+ customizePom(pom, docTitle)
122+
123+ from components. java
124+ artifact sourcesJar
125+ artifact javadocJar
126+ }
127+ }
128+ repositories {
129+ maven {
130+ url " https://oss.sonatype.org/service/local/staging/deploy/maven2"
131+ credentials {
132+ username System . getenv(' MAVEN_CENTRAL_USERNAME' )
133+ password System . getenv(' MAVEN_CENTRAL_PASSWORD' )
142134 }
143135 }
144136 }
145137 }
138+
139+ signing {
140+ // skip signing for "local" version into MavenLocal for test-app
141+ required { ! version. equals(" local" ) }
142+
143+ def signingKey = System . getenv(' MAVEN_SIGNING_KEY' )
144+ def signingPassword = System . getenv(' MAVEN_SIGNING_PASSPHRASE' )
145+ useInMemoryPgpKeys(signingKey, signingPassword)
146+ sign publishing. publications. release
147+ }
146148 }
147149
148150 license {
@@ -153,42 +155,20 @@ subprojects {
153155 ext. year = Calendar . getInstance(). get(Calendar . YEAR )
154156 }
155157
156- def bintrayName = ' core-api' ;
157- if (name. equals(' core-httpclient-impl' )) {
158- bintrayName = ' httpclient'
159- }
160-
161- bintray {
162- user = System . getenv(' BINTRAY_USER' )
163- key = System . getenv(' BINTRAY_KEY' )
164- pkg {
165- repo = ' optimizely'
166- name = " optimizely-sdk-${ bintrayName} "
167- userOrg = ' optimizely'
168- version {
169- name = rootProject. version
170- }
171- publications = [' mavenJava' ]
172- }
173- }
174-
175- build. dependsOn(' generatePomFileForMavenJavaPublication' )
176-
177- bintrayUpload. dependsOn ' build'
178-
179158 task ship() {
180- dependsOn(' bintrayUpload ' )
159+ dependsOn(' publish ' )
181160 }
182161
162+ // concurrent publishing (maven-publish) causes an issue with maven-central repository
163+ // - a single module splits into multiple staging repos, so validation fails.
164+ // - adding this ordering requirement forces sequential publishing processes.
165+ project(' :core-api' ). javadocJar. mustRunAfter = [' :core-httpclient-impl:ship' ]
183166}
184167
185168task ship () {
186169 dependsOn(' :core-api:ship' , ' :core-httpclient-impl:ship' )
187170}
188171
189- // Only report code coverage for projects that are distributed
190- def publishedProjects = subprojects. findAll { it. path != ' :simulator' }
191-
192172task jacocoMerge (type : JacocoMerge ) {
193173 publishedProjects. each { subproject ->
194174 executionData subproject. tasks. withType(Test )
@@ -225,3 +205,37 @@ tasks.coveralls {
225205 dependsOn jacocoRootReport
226206 onlyIf { System . env. ' CI' && ! JavaVersion . current(). isJava9Compatible() }
227207}
208+
209+ // standard POM format required by MavenCentral
210+
211+ def customizePom (pom , title ) {
212+ pom. withXml {
213+ asNode(). children(). last() + {
214+ // keep this - otherwise some properties are not made into pom properly
215+ resolveStrategy = Closure . DELEGATE_FIRST
216+
217+ name title
218+ url ' https://github.com/optimizely/java-sdk'
219+ description ' The Java SDK for Optimizely Full Stack (feature flag management for product development teams)'
220+ licenses {
221+ license {
222+ name ' The Apache Software License, Version 2.0'
223+ url ' http://www.apache.org/licenses/LICENSE-2.0.txt'
224+ distribution ' repo'
225+ }
226+ }
227+ developers {
228+ developer {
229+ id ' optimizely'
230+ name ' Optimizely'
231+ 232+ }
233+ }
234+ scm {
235+ connection ' scm:git:git://github.com/optimizely/java-sdk.git'
236+ developerConnection ' scm:git:ssh:github.com/optimizely/java-sdk.git'
237+ url ' https://github.com/optimizely/java-sdk.git'
238+ }
239+ }
240+ }
241+ }
0 commit comments