Skip to content

Commit 0215660

Browse files
[FSSDK-11782] chore: migrate publishing process from OSSRH to maven central portal (#581)
1 parent cd32b16 commit 0215660

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

build.gradle

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ plugins {
66
id 'com.github.hierynomus.license' version '0.16.1'
77
id 'com.github.spotbugs' version "6.0.14"
88
id 'maven-publish'
9+
id 'signing'
10+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
911
}
1012

1113
allprojects {
1214
apply plugin: 'idea'
1315
apply plugin: 'jacoco'
1416

1517
repositories {
16-
jcenter()
18+
mavenCentral()
19+
maven {
20+
url 'https://plugins.gradle.org/m2/'
21+
}
1722
}
1823

1924
jacoco {
@@ -24,9 +29,9 @@ allprojects {
2429
allprojects {
2530
group = 'com.optimizely.ab'
2631

27-
def travis_defined_version = System.getenv('GITHUB_TAG')
28-
if (travis_defined_version != null) {
29-
version = travis_defined_version
32+
def github_tagged_version = System.getenv('GITHUB_TAG')
33+
if (github_tagged_version != null) {
34+
version = github_tagged_version
3035
}
3136

3237
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
@@ -47,13 +52,6 @@ configure(publishedProjects) {
4752
sourceCompatibility = 1.8
4853
targetCompatibility = 1.8
4954

50-
repositories {
51-
jcenter()
52-
maven {
53-
url 'https://plugins.gradle.org/m2/'
54-
}
55-
}
56-
5755
task sourcesJar(type: Jar, dependsOn: classes) {
5856
archiveClassifier.set('sources')
5957
from sourceSets.main.allSource
@@ -120,7 +118,6 @@ configure(publishedProjects) {
120118
}
121119
}
122120

123-
124121
def docTitle = "Optimizely Java SDK"
125122
if (name.equals('core-httpclient-impl')) {
126123
docTitle = "Optimizely Java SDK: Httpclient"
@@ -137,17 +134,6 @@ configure(publishedProjects) {
137134
artifact javadocJar
138135
}
139136
}
140-
repositories {
141-
maven {
142-
def releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
143-
def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots"
144-
url = isReleaseVersion ? releaseUrl : snapshotUrl
145-
credentials {
146-
username System.getenv('MAVEN_CENTRAL_USERNAME')
147-
password System.getenv('MAVEN_CENTRAL_PASSWORD')
148-
}
149-
}
150-
}
151137
}
152138

153139
signing {
@@ -183,7 +169,18 @@ configure(publishedProjects) {
183169
}
184170

185171
task ship() {
186-
dependsOn(':core-api:ship', ':core-httpclient-impl:ship')
172+
dependsOn(':core-httpclient-impl:ship', ':core-api:ship', 'publishToSonatype', 'closeSonatypeStagingRepository')
173+
}
174+
175+
nexusPublishing {
176+
repositories {
177+
sonatype {
178+
nexusUrl.set(uri('https://ossrh-staging-api.central.sonatype.com/service/local/'))
179+
snapshotRepositoryUrl.set(uri('https://central.sonatype.com/repository/maven-snapshots/'))
180+
username = System.getenv('MAVEN_CENTRAL_USERNAME')
181+
password = System.getenv('MAVEN_CENTRAL_PASSWORD')
182+
}
183+
}
187184
}
188185

189186
task jacocoMerge(type: JacocoMerge) {
@@ -224,7 +221,6 @@ tasks.coveralls {
224221
}
225222

226223
// standard POM format required by MavenCentral
227-
228224
def customizePom(pom, title) {
229225
pom.withXml {
230226
asNode().children().last() + {

0 commit comments

Comments
 (0)