Skip to content

Commit

Permalink
feat: add sonatype repo (#982)
Browse files Browse the repository at this point in the history
* feat: add sonatype repo

* add pom

* set properties

* add debug option

* remove task prepareRelease
  • Loading branch information
JoeWang1127 committed Jan 18, 2024
1 parent ccfe166 commit e736975
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .kokoro/stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ GRADLE_SETTING_FILE=$(realpath .)/app-gradle-plugin/gradle.properties
create_gradle_properties_file "${GRADLE_SETTING_FILE}"
pushd app-gradle-plugin
if [[ -n "${AUTORELEASE_PR}" ]]; then
./gradlew publishMavenJavaPublicationToMavenRepository
echo "Successfully finished './gradlew publishMavenJavaPublicationToMavenRepository'"
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
echo "Successfully finished './gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository'"
else
./gradlew publishMavenJavaPublicationToMavenLocal
./gradlew publishToSonatype
fi
popd # app-gradle-plugin
popd # repository root
103 changes: 39 additions & 64 deletions app-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import net.researchgate.release.GitAdapter.GitConfig
import java.util.Date
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import java.beans.EventHandler.create

/*
* Copyright 2022 Google LLC. All Rights Reserved.
Expand Down Expand Up @@ -32,6 +31,7 @@ plugins {
id("checkstyle")
id("jacoco")
id("maven-publish")
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("signing")
}

Expand Down Expand Up @@ -120,7 +120,6 @@ tasks.register<Test>("integTest") {
}
/* TESTING */


/* RELEASING */
tasks.register<Jar>("sourceJar") {
from(sourceSets.main.get().allJava)
Expand All @@ -133,63 +132,7 @@ tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
}

project.afterEvaluate {
tasks.register("writePom") {
val outputFile = file("$buildDir/pom/${project.name}-${project.version}.pom")
outputs.file(outputFile)

doLast {
maven {
pom {
project {
withGroovyBuilder {
"name"("App Engine Gradle Plugin")
"description"("This Gradle plugin provides tasks to build and deploy Google App Engine applications.")

"url"("https://github.com/GoogleCloudPlatform/app-gradle-plugin")
"inceptionYear"("2016")

"scm" {
"url"("https://github.com/GoogleCloudPlatform/app-gradle-plugin")
"connection"("scm:https://github.com/GoogleCloudPlatform/app-gradle-plugin.git")
"developerConnection"("scm:git://github.com/GoogleCloudPlatform/app-gradle-plugin.git")
}

"licenses" {
"license" {
"name"("The Apache Software License, Version 2.0")
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
"distribution"("repo")
}
}
"developers" {
"developer" {
"id"("loosebazooka")
"name"("Appu Goundan")
"email"("appu@google.com")
}
}
}
}
}.writeTo(outputFile)
}
}
}
}


// for kokoro releases
tasks.register<Sync>("prepareRelease") {
from(tasks.jar)
from(tasks.named("sourceJar"))
from(tasks.named("javadocJar"))
from(tasks.named("writePom"))

into("${buildDir}/release-artifacts")

dependsOn(tasks.build)
}

release {
tagTemplate = "v\$version"
getProperty("git").apply {
Expand All @@ -203,21 +146,53 @@ publishing {
create<MavenPublication>("mavenJava") {
artifactId = "appengine-gradle-plugin"
from(components["java"])
artifact(tasks.named("sourceJar"))
artifact(tasks.named("javadocJar"))

pom {
name.set("App Engine Gradle Plugin")
description.set("This Gradle plugin provides tasks to build and deploy Google App Engine applications.")
url.set("https://github.com/GoogleCloudPlatform/appengine-plugins")
inceptionYear.set("2016")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("loosebazooka")
name.set("Appu Goundan")
email.set("appu@google.com")
}
}
scm {
connection.set("https://github.com/GoogleCloudPlatform/appengine-plugins")
developerConnection.set("scm:git://github.com/GoogleCloudPlatform/appengine-plugins.git")
url.set("https://github.com/GoogleCloudPlatform/appengine-plugins")
}
}
}
}
}

nexusPublishing {
repositories {
maven {
url = uri("https://google.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = findProperty("ossrhUsername").toString()
password = findProperty("ossrhPassword").toString()
sonatype {
nexusUrl.set(uri("https://google.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://google.oss.sonatype.org/content/repositories/snapshots"))
if (project.hasProperty("ossrhUsername")) {
username.set(project.property("ossrhUsername").toString())
password.set(project.property("ossrhPassword").toString())
}
}
}
}

signing {
setRequired({ gradle.taskGraph.hasTask(":${name}:publishMavenJavaPublicationToMavenRepository") })
setRequired({ gradle.taskGraph.hasTask(":${name}:publishToSonatype") })
if (project.hasProperty("signing.gnupg.executable")) {
useGpgCmd()
}
Expand Down

0 comments on commit e736975

Please sign in to comment.