18
18
19
19
buildscript {
20
20
ext. kotlin_version = ' 1.4.0'
21
- def bintray_user = System . getenv(' BINTRAY_USER' )
22
- def bintray_api_key = System . getenv(' BINTRAY_API_KEY' )
21
+
23
22
def version_name = System . getenv(' TRAVIS_TAG' )
24
- if (bintray_user != null && bintray_api_key != null && version_name != null ) {
25
- rootProject. ext. bintray_user = bintray_user
26
- rootProject. ext. bintray_api_key = bintray_api_key
23
+ if (version_name != null ) {
27
24
rootProject. ext. version_name = version_name
28
25
} else {
29
- rootProject. ext. bintray_user = ' '
30
- rootProject. ext. bintray_api_key = ' '
31
26
rootProject. ext. version_name= ' debugVersion'
32
27
}
33
28
repositories {
58
53
build_tools_version = " 29.0.3"
59
54
min_sdk_version = 14
60
55
target_sdk_version = 29
61
- java_core_ver = " 3.8.0 "
56
+ java_core_ver = " 3.8.1 "
62
57
android_logger_ver = " 1.3.6"
63
58
jacksonversion= " 2.11.2"
64
59
annotations_ver = " 1.0.0"
75
70
}
76
71
77
72
task clean (type : Delete ) {
78
- delete rootProject. buildDir
79
- }
80
-
81
- task ship () {
82
- dependsOn(' :android-sdk:uploadArchives' , ' :shared:uploadArchives' ,
83
- ' event-handler:uploadArchives' , ' user-profile:uploadArchives' ,
84
- ' datafile-handler:uploadArchives' )
73
+ dependsOn(' cleanAllModules' )
85
74
}
86
75
87
76
task cleanAllModules () {
@@ -105,3 +94,170 @@ testAllModulesTravis.dependsOn(':android-sdk:connectedAndroidTest', ':android-sd
105
94
' :user-profile:connectedAndroidTest' , ' :shared:connectedAndroidTest' )
106
95
107
96
testAllModules. dependsOn(' testAllModulesTravis' , ' :test-app:connectedAndroidTest' )
97
+
98
+ // Publish to MavenCentral
99
+
100
+ task ship () {
101
+ dependsOn(' :android-sdk:ship' , ' :shared:ship' , ' :event-handler:ship' , ' :user-profile:ship' , ' :datafile-handler:ship' )
102
+ }
103
+
104
+ def publishedProjects = subprojects. findAll { it. name != ' test-app' }
105
+ configure(publishedProjects) {
106
+ apply plugin : ' com.android.library'
107
+ apply plugin : ' kotlin-android'
108
+ apply plugin : ' kotlin-android-extensions'
109
+ apply plugin : ' maven-publish'
110
+ apply plugin : ' signing'
111
+
112
+ def artifactName = " android-sdk"
113
+ def docTitle = " Optimizely Android SDK"
114
+ switch (name){
115
+ case ' android-sdk' :
116
+ artifactName = ' android-sdk'
117
+ docTitle = ' Optimizely Android SDK'
118
+ break
119
+ case ' datafile-handler' :
120
+ artifactName = ' android-sdk-datafile-handler'
121
+ docTitle = ' Optimizely Android SDK: Datafile Handler'
122
+ break
123
+ case ' event-handler' :
124
+ artifactName = ' android-sdk-event-handler'
125
+ docTitle = ' Optimizely Android SDK: Event Handler'
126
+ break
127
+ case ' shared' :
128
+ artifactName = ' android-sdk-shared'
129
+ docTitle = ' Optimizely Android SDK: Shared'
130
+ break
131
+ case ' user-profile' :
132
+ artifactName = ' android-sdk-user-profile'
133
+ docTitle = ' Optimizely X Android SDK: User Profile'
134
+ break
135
+ default :
136
+ return
137
+ }
138
+
139
+ android. libraryVariants. all { variant ->
140
+ task(" ${ variant.name} Javadoc" , type : Javadoc , dependsOn : " assemble${ variant.name.capitalize()} " ) {
141
+ source = variant. javaCompile. source
142
+
143
+ title = docTitle
144
+
145
+ options. links(" http://docs.oracle.com/javase/7/docs/api/" );
146
+
147
+ // First add all of your dependencies to the classpath, then add the android jars
148
+ doFirst {
149
+ classpath + = files(variant. javaCompileProvider. get(). classpath. files)
150
+ classpath + = files(android. getBootClasspath())
151
+ }
152
+ // We're excluding these generated files
153
+ exclude ' **/BuildConfig.java'
154
+ exclude ' **/R.java'
155
+
156
+ options. tags = [" hide" ]
157
+ }
158
+ }
159
+
160
+ android. libraryVariants. all { variant ->
161
+ task(" ${ variant.name} JavadocJar" , type : Jar , dependsOn : " ${ variant.name} Javadoc" ) {
162
+ classifier = ' javadoc'
163
+ from tasks[" ${ variant.name} Javadoc" ]. destinationDir
164
+ }
165
+
166
+ // Add the Javadoc jar to the project's artifacts. This will allow us to upload it easily later
167
+ project. artifacts. add(" archives" , tasks[" ${ variant.name} JavadocJar" ]);
168
+ }
169
+
170
+ android. libraryVariants. all { variant ->
171
+ task(" ${ variant.name} SourcesJar" , type : Jar ) {
172
+ classifier = ' sources'
173
+ from variant. javaCompile. source
174
+ }
175
+ project. artifacts. add(" archives" , tasks[" ${ variant.name} SourcesJar" ]);
176
+ }
177
+
178
+ afterEvaluate {
179
+ publishing {
180
+ publications {
181
+ release(MavenPublication ) {
182
+ version = version_name
183
+ group = group_id
184
+ artifactId = artifactName
185
+
186
+ customizePom(pom, docTitle)
187
+ // "description" is required by MavenCentral but it does not work in customizePom(). added here explicitly.
188
+ pom. description = ' The Android SDK for Optimizely Full Stack (feature flag management for product development teams)'
189
+
190
+ from components. release
191
+ artifact releaseSourcesJar
192
+ artifact releaseJavadocJar
193
+ }
194
+ }
195
+ repositories {
196
+ maven {
197
+ url " https://oss.sonatype.org/service/local/staging/deploy/maven2"
198
+ credentials {
199
+ username System . getenv(' MAVEN_CENTRAL_USERNAME' )
200
+ password System . getenv(' MAVEN_CENTRAL_PASSWORD' )
201
+ }
202
+ }
203
+ }
204
+ }
205
+
206
+ signing {
207
+ // base64 for workaround travis escape chars issue
208
+ def signingKeyBase64 = System . getenv(' MAVEN_SIGNING_KEY_BASE64' )
209
+ // skip signing for "local" version into MavenLocal
210
+ if (! signingKeyBase64?. trim()) return
211
+ byte [] decoded = signingKeyBase64. decodeBase64()
212
+ def signingKey = new String (decoded)
213
+
214
+ def signingPassword = System . getenv(' MAVEN_SIGNING_PASSPHRASE' )
215
+ useInMemoryPgpKeys(signingKey, signingPassword)
216
+ sign publishing. publications. release
217
+ }
218
+ }
219
+
220
+ task ship() {
221
+ dependsOn(' publish' )
222
+ }
223
+ }
224
+
225
+ project(' :android-sdk' ). ship. shouldRunAfter = [' :android-sdk:clean' , ' :datafile-handler:ship' , ' :event-handler:ship' , ' :user-profile:ship' ]
226
+ project(' :datafile-handler' ). ship. shouldRunAfter = [' :datafile-handler:clean' , ' :shared:ship' ]
227
+ project(' :event-handler' ). ship. shouldRunAfter = [' :event-handler:clean' , ' :shared:ship' ]
228
+ project(' :shared' ). ship. shouldRunAfter = [' :shared:clean' ]
229
+ project(' :user-profile' ). ship. shouldRunAfter = [' :user-profile:clean' , ' :shared:ship' ]
230
+
231
+ // standard POM format required by MavenCentral
232
+
233
+ def customizePom (pom , title ) {
234
+ pom. withXml {
235
+ asNode(). children(). last() + {
236
+ // keep this - otherwise some properties are not made into pom properly
237
+ resolveStrategy = Closure . DELEGATE_FIRST
238
+
239
+ name title
240
+ url ' https://github.com/optimizely/android-sdk'
241
+ licenses {
242
+ license {
243
+ name ' The Apache Software License, Version 2.0'
244
+ url ' http://www.apache.org/licenses/LICENSE-2.0.txt'
245
+ distribution ' repo'
246
+ }
247
+ }
248
+ developers {
249
+ developer {
250
+ id ' optimizely'
251
+ name ' Optimizely'
252
+
253
+ }
254
+ }
255
+ scm {
256
+ connection ' scm:git:git://github.com/optimizely/android-sdk.git'
257
+ developerConnection ' scm:git:ssh:github.com/optimizely/android-sdk.git'
258
+ url ' https://github.com/optimizely/android-sdk.git'
259
+ }
260
+ }
261
+ }
262
+ }
263
+
0 commit comments