Skip to content

Commit e736975

Browse files
authored
feat: add sonatype repo (#982)
* feat: add sonatype repo * add pom * set properties * add debug option * remove task prepareRelease
1 parent ccfe166 commit e736975

File tree

2 files changed

+42
-67
lines changed

2 files changed

+42
-67
lines changed

.kokoro/stage.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ GRADLE_SETTING_FILE=$(realpath .)/app-gradle-plugin/gradle.properties
6969
create_gradle_properties_file "${GRADLE_SETTING_FILE}"
7070
pushd app-gradle-plugin
7171
if [[ -n "${AUTORELEASE_PR}" ]]; then
72-
./gradlew publishMavenJavaPublicationToMavenRepository
73-
echo "Successfully finished './gradlew publishMavenJavaPublicationToMavenRepository'"
72+
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
73+
echo "Successfully finished './gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository'"
7474
else
75-
./gradlew publishMavenJavaPublicationToMavenLocal
75+
./gradlew publishToSonatype
7676
fi
7777
popd # app-gradle-plugin
7878
popd # repository root

app-gradle-plugin/build.gradle.kts

Lines changed: 39 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import net.researchgate.release.GitAdapter.GitConfig
22
import java.util.Date
33
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
4-
import java.beans.EventHandler.create
54

65
/*
76
* Copyright 2022 Google LLC. All Rights Reserved.
@@ -32,6 +31,7 @@ plugins {
3231
id("checkstyle")
3332
id("jacoco")
3433
id("maven-publish")
34+
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
3535
id("signing")
3636
}
3737

@@ -120,7 +120,6 @@ tasks.register<Test>("integTest") {
120120
}
121121
/* TESTING */
122122

123-
124123
/* RELEASING */
125124
tasks.register<Jar>("sourceJar") {
126125
from(sourceSets.main.get().allJava)
@@ -133,63 +132,7 @@ tasks.register<Jar>("javadocJar") {
133132
archiveClassifier.set("javadoc")
134133
}
135134

136-
project.afterEvaluate {
137-
tasks.register("writePom") {
138-
val outputFile = file("$buildDir/pom/${project.name}-${project.version}.pom")
139-
outputs.file(outputFile)
140-
141-
doLast {
142-
maven {
143-
pom {
144-
project {
145-
withGroovyBuilder {
146-
"name"("App Engine Gradle Plugin")
147-
"description"("This Gradle plugin provides tasks to build and deploy Google App Engine applications.")
148-
149-
"url"("https://github.com/GoogleCloudPlatform/app-gradle-plugin")
150-
"inceptionYear"("2016")
151-
152-
"scm" {
153-
"url"("https://github.com/GoogleCloudPlatform/app-gradle-plugin")
154-
"connection"("scm:https://github.com/GoogleCloudPlatform/app-gradle-plugin.git")
155-
"developerConnection"("scm:git://github.com/GoogleCloudPlatform/app-gradle-plugin.git")
156-
}
157-
158-
"licenses" {
159-
"license" {
160-
"name"("The Apache Software License, Version 2.0")
161-
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
162-
"distribution"("repo")
163-
}
164-
}
165-
"developers" {
166-
"developer" {
167-
"id"("loosebazooka")
168-
"name"("Appu Goundan")
169-
"email"("appu@google.com")
170-
}
171-
}
172-
}
173-
}
174-
}.writeTo(outputFile)
175-
}
176-
}
177-
}
178-
}
179-
180-
181135
// for kokoro releases
182-
tasks.register<Sync>("prepareRelease") {
183-
from(tasks.jar)
184-
from(tasks.named("sourceJar"))
185-
from(tasks.named("javadocJar"))
186-
from(tasks.named("writePom"))
187-
188-
into("${buildDir}/release-artifacts")
189-
190-
dependsOn(tasks.build)
191-
}
192-
193136
release {
194137
tagTemplate = "v\$version"
195138
getProperty("git").apply {
@@ -203,21 +146,53 @@ publishing {
203146
create<MavenPublication>("mavenJava") {
204147
artifactId = "appengine-gradle-plugin"
205148
from(components["java"])
149+
artifact(tasks.named("sourceJar"))
150+
artifact(tasks.named("javadocJar"))
151+
152+
pom {
153+
name.set("App Engine Gradle Plugin")
154+
description.set("This Gradle plugin provides tasks to build and deploy Google App Engine applications.")
155+
url.set("https://github.com/GoogleCloudPlatform/appengine-plugins")
156+
inceptionYear.set("2016")
157+
licenses {
158+
license {
159+
name.set("The Apache Software License, Version 2.0")
160+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
161+
distribution.set("repo")
162+
}
163+
}
164+
developers {
165+
developer {
166+
id.set("loosebazooka")
167+
name.set("Appu Goundan")
168+
email.set("appu@google.com")
169+
}
170+
}
171+
scm {
172+
connection.set("https://github.com/GoogleCloudPlatform/appengine-plugins")
173+
developerConnection.set("scm:git://github.com/GoogleCloudPlatform/appengine-plugins.git")
174+
url.set("https://github.com/GoogleCloudPlatform/appengine-plugins")
175+
}
176+
}
206177
}
207178
}
179+
}
180+
181+
nexusPublishing {
208182
repositories {
209-
maven {
210-
url = uri("https://google.oss.sonatype.org/service/local/staging/deploy/maven2/")
211-
credentials {
212-
username = findProperty("ossrhUsername").toString()
213-
password = findProperty("ossrhPassword").toString()
183+
sonatype {
184+
nexusUrl.set(uri("https://google.oss.sonatype.org/service/local/"))
185+
snapshotRepositoryUrl.set(uri("https://google.oss.sonatype.org/content/repositories/snapshots"))
186+
if (project.hasProperty("ossrhUsername")) {
187+
username.set(project.property("ossrhUsername").toString())
188+
password.set(project.property("ossrhPassword").toString())
214189
}
215190
}
216191
}
217192
}
218193

219194
signing {
220-
setRequired({ gradle.taskGraph.hasTask(":${name}:publishMavenJavaPublicationToMavenRepository") })
195+
setRequired({ gradle.taskGraph.hasTask(":${name}:publishToSonatype") })
221196
if (project.hasProperty("signing.gnupg.executable")) {
222197
useGpgCmd()
223198
}

0 commit comments

Comments
 (0)