From 9cd6c2aa77cb07aede334d2dab318848c6107298 Mon Sep 17 00:00:00 2001 From: sheedon Date: Sun, 29 May 2022 18:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=96=87=E4=BB=B6=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + script/gradle-jcenter-push.gradle | 173 +++++++++++++++++++++--------- 2 files changed, 124 insertions(+), 50 deletions(-) diff --git a/build.gradle b/build.gradle index 36b14c1..3d700a5 100644 --- a/build.gradle +++ b/build.gradle @@ -14,6 +14,7 @@ buildscript { classpath "com.android.tools.build:gradle:4.2.2" classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/script/gradle-jcenter-push.gradle b/script/gradle-jcenter-push.gradle index 9abeb72..586f51f 100644 --- a/script/gradle-jcenter-push.gradle +++ b/script/gradle-jcenter-push.gradle @@ -1,60 +1,133 @@ -apply plugin: 'maven-publish' +apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.github.dcendents.android-maven' group = POM_GROUP_ID version = VERSION_NAME -afterEvaluate { - publishing { - publications { - maven(MavenPublication) { - - pom{ - groupId = POM_GROUP_ID - artifactId = POM_ARTIFACT_ID - version = VERSION_NAME + POM_PACKAGING - } - - if (project.hasProperty("android")) { // Android libraries - from components.release - artifact androidSourcesJar - task sourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.kotlin.srcDirs - } - - task javadoc(type: Javadoc) { - failOnError false - source = android.sourceSets.main.kotlin.srcDirs - options { - links "http://docs.oracle.com/javase/7/docs/api/" - linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference" - } - classpath += project.android.libraryVariants.toList().first().javaCompile.classpath - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - } - } else { // Java libraries - from components.java - task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.java.srcDirs - } - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - - artifacts { - archives javadocJar - archives sourcesJar - } +afterEvaluate { project -> + install { + repositories.mavenInstaller { + configurePOM(pom); + } + } + + if (project.hasProperty("android")) { // Android libraries + task sourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + } + + task javadoc(type: Javadoc) { + failOnError false + source = android.sourceSets.main.java.srcDirs + options { + links "http://docs.oracle.com/javase/7/docs/api/" + linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference" } + classpath += project.android.libraryVariants.toList().first().javaCompile.classpath + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } + } else { // Java libraries + task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.java.srcDirs + } + } + + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir + } + + artifacts { + archives javadocJar + archives sourcesJar } } -task androidSourcesJar(type: Jar) { - archiveClassifier.set('sources') - from android.sourceSets.main.java.srcDirs +private configurePOM(def pom) { + pom.project { + packaging POM_PACKAGING + groupId POM_GROUP_ID + artifactId POM_ARTIFACT_ID + + name POM_NAME + description POM_DESCRIPTION + url POM_URL + + version VERSION_NAME + inceptionYear POM_INCEPTION_YEAR + + licenses { + license { + name POM_LICENCE_NAME + url POM_LICENCE_URL + distribution POM_LICENCE_DIST + comments POM_LICENCE_COMMENTS + } + } + + developers { + developer { + id POM_DEVELOPER_ID + name POM_DEVELOPER_NAME +// email POM_DEVELOPER_EMAIL +// url POM_DEVELOPER_URL + } + } + + scm { + url POM_SCM_URL + connection POM_SCM_CONNECTION + developerConnection POM_SCM_DEV_CONNECTION + } + + issueManagement { + system POM_ISSUE_MANAGEMENT_SYSTEM + url POM_ISSUE_MANAGEMENT_URL + } + } +} + +// Default Bintray +def getRepositoryUser() { + return hasProperty('BINTRAY_USER') ? BINTRAY_USER : "" +} + +def getRepositoryKey() { + return hasProperty('BINTRAY_KEY') ? BINTRAY_KEY : "" +} + +def getRepositoryGPGPassword() { + return hasProperty('BINTRAY_GPG_PASSWORD') ? BINTRAY_GPG_PASSWORD : "" +} + +bintray { + user = getRepositoryUser(); + key = getRepositoryKey(); + + group = POM_GROUP_ID + version = VERSION_NAME + + configurations = ['archives'] + + pkg { + repo = POM_BINTRAY_PRPO + name = POM_BINTRAY_NAME + desc = POM_DESCRIPTION + websiteUrl = POM_URL + vcsUrl = POM_GIT_URL + licenses = POM_LICENCE_ALL + publish = true + publicDownloadNumbers = true + version { + desc = POM_DESCRIPTION + gpg { + sign = !(getRepositoryGPGPassword() == null || getRepositoryGPGPassword() == ""); + // true //Determines whether to GPG sign the files. The default is false + passphrase = getRepositoryGPGPassword(); + //Optional. The passphrase for GPG signing' + } + } + } }