Skip to content

Commit 9be322f

Browse files
Implement JReleaser plugin for Central Portal migration (#835)
* Add new central portal releaseRepoUrl * Implement JReleaser plugin * Fix typo and indentation * Updated comments, fixed staging repo location, removed some old OSSRH tests
1 parent 9a166c7 commit 9be322f

4 files changed

Lines changed: 46 additions & 33 deletions

File tree

buildSrc/src/main/groovy/com.google.api-ads.java-conventions.gradle

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,11 @@ publishing {
9191
fromResolutionResult()
9292
}
9393
}
94-
}
95-
}
96-
repositories {
97-
maven {
98-
def releaseRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
99-
def snapshotRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
100-
101-
// Set the URL dynamically based on the project version
102-
url = project.version.endsWith('SNAPSHOT') ? snapshotRepoUrl : releaseRepoUrl
103-
name = "sonatype"
104-
credentials {
105-
// Avoids storing Sonatype credentials in plain-text. Specify these on
106-
// the command line: -PsonatypeUser=foo
107-
username project.properties.get("sonatypeUser")
108-
password project.properties.get("sonatypePassword")
94+
repositories {
95+
maven {
96+
name = 'sonatype'
97+
url = uri(layout.buildDirectory.dir("staging-deploy"))
98+
}
10999
}
110100
}
111101
}
@@ -117,22 +107,6 @@ publishing {
117107
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
118108
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
119109

120-
// Provide a helpful error message for missing sonatype credentials.
121-
tasks.findAll {
122-
if (it.name.matches("publish.+ToSonatypeRepository")) {
123-
it.doFirst {
124-
def user = project.properties.get("sonatypeUser")
125-
def pass = project.properties.get("sonatypePassword")
126-
if (user == null || user.length() == 0) {
127-
throw new GradleException("Missing property for sonatype username, try -PsonatypeUser=foo")
128-
}
129-
if (pass == null || pass.length() == 0) {
130-
throw new GradleException("Missing property for sonatype password, try -PsonatypePassword=foo")
131-
}
132-
}
133-
}
134-
}
135-
136110
ext.configurePom = { publication, nameToSet, descriptionToSet ->
137111
publication.pom {
138112
name = nameToSet
@@ -172,6 +146,13 @@ ext.configurePom = { publication, nameToSet, descriptionToSet ->
172146
organization = 'Google'
173147
organizationUrl = 'https://www.google.com'
174148
}
149+
developer {
150+
id = 'sarah'
151+
name = 'Sarah Pollack'
152+
email = 'sarahbot@users.noreply.github.com'
153+
organization = 'Google'
154+
organizationUrl = 'https://www.google.com'
155+
}
175156
}
176157
}
177158
}

google-ads/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,42 @@ plugins {
2929
id 'com.google.api-ads.java-conventions'
3030
id 'com.google.protobuf' version '0.8.15'
3131
id "com.github.hierynomus.license-report" version "0.16.1"
32+
id 'org.jreleaser' version '1.18.0'
3233
}
3334

3435
description = 'Google Ads API client library for Java'
3536

37+
jreleaser {
38+
project {
39+
gitRootSearch = true // Allow JReleaser to search upwards for .git
40+
}
41+
signing {
42+
active = 'ALWAYS'
43+
armored = true
44+
}
45+
deploy {
46+
maven {
47+
mavenCentral {
48+
sonatype {
49+
/** Warning: In your JReleaser config file set
50+
* JRELEASER_MAVENCENTRAL_STAGE to 'UPLOAD' in order to
51+
* prevent the deployment from automatically publishing
52+
* without any UI intervention. */
53+
active = 'ALWAYS'
54+
url = 'https://central.sonatype.com/api/v1/publisher'
55+
stagingRepository(layout.buildDirectory.dir("staging-deploy").get().toString())
56+
stage = 'UPLOAD'
57+
}
58+
}
59+
release {
60+
github {
61+
skipRelease = true
62+
skipTag = true
63+
}
64+
}
65+
}
66+
}
67+
}
3668
protobuf {
3769
protoc {
3870
artifact = 'com.google.protobuf:protoc:3.25.3'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ org.gradle.caching=true
44
org.gradle.parallel=true
55
org.gradle.jvmargs=-Xmx5g -XX\:MaxMetaspaceSize\=2048m -XX\:+HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
66
org.gradle.console=rich
7-
version=36.1.1-SNAPSHOT
7+
version=36.1.1
88
group=com.google.api-ads
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)