@@ -5,11 +5,9 @@ plugins {
5
5
id ' nebula.optional-base' version ' 3.2.0'
6
6
id ' com.github.hierynomus.license' version ' 0.15.0'
7
7
id ' com.github.spotbugs' version " 4.5.0"
8
- id " com.jfrog.bintray" version " 1.8.5"
9
8
}
10
9
11
10
allprojects {
12
- group = ' com.optimizely.ab'
13
11
apply plugin : ' idea'
14
12
apply plugin : ' jacoco'
15
13
@@ -22,26 +20,27 @@ allprojects {
22
20
}
23
21
}
24
22
25
- apply from : ' gradle/publish.gradle'
26
-
27
23
allprojects {
24
+ group = ' com.optimizely.ab'
25
+
28
26
def travis_defined_version = System . getenv(' TRAVIS_TAG' )
29
27
if (travis_defined_version != null ) {
30
28
version = travis_defined_version
31
29
}
32
30
}
33
31
34
- subprojects {
35
- apply plugin : ' com.jfrog.bintray'
32
+ def publishedProjects = subprojects. findAll { it. name != ' java-quickstart' }
33
+
34
+ configure(publishedProjects) {
36
35
apply plugin : ' com.github.spotbugs'
37
36
apply plugin : ' jacoco'
38
37
apply plugin : ' java'
39
38
apply plugin : ' maven-publish'
39
+ apply plugin : ' signing'
40
40
apply plugin : ' me.champeau.gradle.jmh'
41
41
apply plugin : ' nebula.optional-base'
42
42
apply plugin : ' com.github.hierynomus.license'
43
43
44
-
45
44
sourceCompatibility = 1.8
46
45
targetCompatibility = 1.8
47
46
@@ -62,11 +61,6 @@ subprojects {
62
61
from javadoc. destinationDir
63
62
}
64
63
65
- artifacts {
66
- archives sourcesJar
67
- archives javadocJar
68
- }
69
-
70
64
spotbugsMain {
71
65
reports {
72
66
xml. enabled = false
@@ -115,34 +109,42 @@ subprojects {
115
109
testCompile group : ' com.fasterxml.jackson.core' , name : ' jackson-databind' , version : jacksonVersion
116
110
}
117
111
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
- email ' developers@optimizely.com'
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' )
142
134
}
143
135
}
144
136
}
145
137
}
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
+ }
146
148
}
147
149
148
150
license {
@@ -153,42 +155,20 @@ subprojects {
153
155
ext. year = Calendar . getInstance(). get(Calendar . YEAR )
154
156
}
155
157
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
-
179
158
task ship() {
180
- dependsOn(' bintrayUpload ' )
159
+ dependsOn(' publish ' )
181
160
}
182
161
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' ]
183
166
}
184
167
185
168
task ship () {
186
169
dependsOn(' :core-api:ship' , ' :core-httpclient-impl:ship' )
187
170
}
188
171
189
- // Only report code coverage for projects that are distributed
190
- def publishedProjects = subprojects. findAll { it. path != ' :simulator' }
191
-
192
172
task jacocoMerge (type : JacocoMerge ) {
193
173
publishedProjects. each { subproject ->
194
174
executionData subproject. tasks. withType(Test )
@@ -225,3 +205,37 @@ tasks.coveralls {
225
205
dependsOn jacocoRootReport
226
206
onlyIf { System . env. ' CI' && ! JavaVersion . current(). isJava9Compatible() }
227
207
}
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
+ email ' optimizely-fullstack@optimizely.com'
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