From 37a1773a8beb4e17b1baebe9fb61d018301cd379 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Mon, 10 May 2021 09:13:49 +0800 Subject: [PATCH] Update the maven publish plugin --- plugin/build.gradle.kts | 62 ++++++++++++++++++++++++++++++++++------ plugin/gradle.properties | 22 -------------- 2 files changed, 54 insertions(+), 30 deletions(-) delete mode 100644 plugin/gradle.properties diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 65d23d2b94..ae7ea3882a 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,26 +1,72 @@ plugins { id("com.android.library") - id("com.vanniktech.maven.publish") + id("maven-publish") kotlin("android") id("kotlin-parcelize") + signing } setupCommon() android { defaultConfig { - versionCode = findProperty("VERSION_CODE").toString().toInt() - versionName = findProperty("VERSION_NAME").toString() + versionCode = 10 + versionName = "2.0.1" } lintOptions.informational("GradleDependency") } -mavenPublish.targets.getByName("uploadArchives") { - releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/" - repositoryUsername = findProperty("NEXUS_USERNAME").toString() - repositoryPassword = findProperty("NEXUS_PASSWORD").toString() +afterEvaluate { + publishing { + publications { + create("release") { + from(components["release"]) + + groupId = "com.github.shadowsocks" + artifactId = "plugin" + version = android.defaultConfig.versionName + + pom { + name.set("Shadowsocks Plugin") + description.set("SIP003 plugin for Shadowsocks") + url.set("http://www.example.com/library") + licenses { + license { + name.set("The GNU General Public License v3.0") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + } + } + developers { + developer { + id.set("Mygod") + name.set("Mygod Studio") + email.set("contact-github@mygod.be") + } + } + scm { + connection.set("scm:git:git://github.com/shadowsocks/shadowsocks-android.git") + developerConnection.set("scm:git:git://github.com/shadowsocks/shadowsocks-android.git") + url.set("https://github.com/shadowsocks/shadowsocks-android") + } + } + } + } + repositories { + maven { + val releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + val snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/" + credentials { + username = findProperty("NEXUS_USERNAME").toString() + password = findProperty("NEXUS_PASSWORD").toString() + } + url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotRepositoryUrl else releaseRepositoryUrl) + } + } + } + signing { + sign(publishing.publications["release"]) + } } dependencies { diff --git a/plugin/gradle.properties b/plugin/gradle.properties deleted file mode 100644 index 71ffb7ce22..0000000000 --- a/plugin/gradle.properties +++ /dev/null @@ -1,22 +0,0 @@ -GROUP=com.github.shadowsocks -VERSION_NAME=2.0.1 -VERSION_CODE=16 - -POM_ARTIFACT_ID=plugin -POM_NAME=Shadowsocks Plugin -POM_PACKAGING=aar - -POM_DESCRIPTION=SIP003 plugin for Shadowsocks -POM_INCEPTION_YEAR=2018 - -POM_URL=https://github.com/shadowsocks/shadowsocks-android -POM_SCM_URL=https://github.com/shadowsocks/shadowsocks-android -POM_SCM_CONNECTION=scm:git:git://github.com/shadowsocks/shadowsocks-android.git -POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/shadowsocks/shadowsocks-android.git - -POM_LICENCE_NAME=The GNU General Public License v3.0 -POM_LICENCE_URL=https://www.gnu.org/licenses/gpl-3.0.html -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=Mygod -POM_DEVELOPER_NAME=Mygod Studio