From 86d50468ac82a0e5ca9e71fa3fbe98e5f4d5c773 Mon Sep 17 00:00:00 2001 From: Zhenjie Yan Date: Sat, 19 Mar 2022 22:33:08 +0800 Subject: [PATCH] Update script and release v2.1.10. --- annotation/build.gradle | 2 +- api/build.gradle | 6 +- bintray.gradle | 142 ---------------------------------- build.gradle | 16 ++-- central.gradle | 166 +++++++++++++++++++++------------------- config.gradle | 1 - gradle.properties | 4 +- plugin/build.gradle | 2 +- processor/build.gradle | 2 +- 9 files changed, 102 insertions(+), 239 deletions(-) delete mode 100644 bintray.gradle diff --git a/annotation/build.gradle b/annotation/build.gradle index 9f631aa..59c328b 100644 --- a/annotation/build.gradle +++ b/annotation/build.gradle @@ -5,4 +5,4 @@ compileJava { targetCompatibility = JavaVersion.VERSION_1_8 } -apply from: '../bintray.gradle' \ No newline at end of file +apply from: '../central.gradle' \ No newline at end of file diff --git a/api/build.gradle b/api/build.gradle index b9e7e00..c084451 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -17,10 +17,10 @@ android { buildTypes { release { - buildConfigField "java.lang.String", "PROJECT_VERSION", "\"${PROJECT_VERSION}\"" + buildConfigField "java.lang.String", "PROJECT_VERSION", "\"${POM_VERSION}\"" } debug { - buildConfigField "java.lang.String", "PROJECT_VERSION", "\"${PROJECT_VERSION}\"" + buildConfigField "java.lang.String", "PROJECT_VERSION", "\"${POM_VERSION}\"" } } } @@ -33,4 +33,4 @@ dependencies { compileOnly deps.android.annotation } -apply from: '../bintray.gradle' \ No newline at end of file +apply from: '../central.gradle' \ No newline at end of file diff --git a/bintray.gradle b/bintray.gradle deleted file mode 100644 index 1a1e9e7..0000000 --- a/bintray.gradle +++ /dev/null @@ -1,142 +0,0 @@ -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.jfrog.bintray' - -group = PROJECT_GROUP -version = PROJECT_VERSION - -afterEvaluate { project -> - uploadArchives { - repositories { - mavenDeployer { - repository(url: mavenLocal().getUrl()) - pom.groupId = PROJECT_GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = PROJECT_VERSION - } - } - } -} - -def getBintrayUsername() { - return hasProperty('BINTRAY_USERNAME') ? BINTRAY_USERNAME : "" -} - -def getBintrayApiKey() { - return hasProperty('BINTRAY_API_KEY') ? BINTRAY_API_KEY : "" -} - -def getGPGPassword() { - return hasProperty('BINTRAY_GPG_PASSWORD') ? BINTRAY_GPG_PASSWORD : "" -} - -def getSonatypeUserName() { - return hasProperty('SONATYPE_USERNAME') ? SONATYPE_USERNAME : "" -} - -def getSonatypePassword() { - return hasProperty('SONATYPE_PASSWORD') ? SONATYPE_PASSWORD : "" -} - -bintray { - user = getBintrayUsername() - key = getBintrayApiKey() - - configurations = ['archives'] - pkg { - repo = 'maven' - name = POM_NAME - desc = POM_DESCRIPTION - websiteUrl = POM_URL - vcsUrl = POM_GIT_URL - licenses = [POM_LICENCE_NAME] - publish = true - publicDownloadNumbers = true - version { - desc = "${POM_NAME} ${PROJECT_VERSION}." - gpg { - sign = true - passphrase = getGPGPassword() - } - mavenCentralSync { - sync = true - user = getSonatypeUserName() - password = getSonatypePassword() - close = '1' - } - } - } -} - -install { - repositories.mavenInstaller { - pom { - project { - name POM_NAME - description POM_DESCRIPTION - url POM_URL - - packaging POM_PACKAGING - groupId PROJECT_GROUP - artifactId POM_ARTIFACT_ID - version PROJECT_VERSION - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - } - } - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_ID - email POM_DEVELOPER_EMAIL - } - } - scm { - url POM_URL - connection POM_GIT_URL - developerConnection POM_GIT_URL - } - } - } - } -} - -if (project.getPlugins().hasPlugin("com.android.library")) { - task sourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.source - } - task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.source - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - failOnError false - } - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } -} else { - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } -} - -if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } -} - -artifacts { - archives sourcesJar - archives javadocJar -} \ No newline at end of file diff --git a/build.gradle b/build.gradle index dec7577..1e876ad 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +1,25 @@ -apply from: "config.gradle" +apply from: 'config.gradle' buildscript { repositories { mavenLocal() - google { url 'https://maven.aliyun.com/repository/google' } - jcenter { url 'https://maven.aliyun.com/repository/jcenter' } - mavenCentral { url 'https://maven.aliyun.com/repository/central' } + google() + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' - classpath "com.yanzhenjie.andserver:plugin:2.1.9" + classpath 'com.yanzhenjie.andserver:plugin:2.1.10' } } allprojects { repositories { mavenLocal() - google { url 'https://maven.aliyun.com/repository/google' } - jcenter { url 'https://maven.aliyun.com/repository/jcenter' } - mavenCentral { url 'https://maven.aliyun.com/repository/central' } + google() + jcenter() + mavenCentral() } } diff --git a/central.gradle b/central.gradle index 9645690..664ebde 100644 --- a/central.gradle +++ b/central.gradle @@ -1,55 +1,86 @@ apply plugin: 'maven' apply plugin: 'signing' -group = PROJECT_GROUP -version = PROJECT_VERSION +configurations.all { + resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds' + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' +} + +group = POM_GROUP_ID +version = POM_VERSION def toRemote = project.hasProperty('toRemote') ? Boolean.valueOf("${toRemote}") : false println("publish to remote repository:${toRemote}") -def configurePom(pom) { - pom.groupId = PROJECT_GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = PROJECT_VERSION +def plugins = project.getPlugins() - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL +def getSonatypeUserName() { + return hasProperty('SONATYPE_USERNAME') ? SONATYPE_USERNAME : "" +} - scm { - url POM_URL - connection POM_GIT_URL - developerConnection POM_GIT_URL +def getSonatypePassword() { + return hasProperty('SONATYPE_PASSWORD') ? SONATYPE_PASSWORD : "" +} + +if (plugins.hasPlugin('com.android.library')) { + task install(type: Upload, dependsOn: assemble) { + repositories.mavenInstaller { + configurePom(pom) } + } - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } + task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.source + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + failOnError false + } + + task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir + } + + task sourcesJar(type: Jar) { + archiveClassifier = 'sources' + from android.sourceSets.main.java.source + } +} else if (plugins.hasPlugin('java-library') || plugins.hasPlugin('java-library')) { + install { + repositories.mavenInstaller { + configurePom(pom) } + } - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } + task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir + } + + task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource + } +} + +if (JavaVersion.current().isJava8Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') } } } -def getSonatypeUserName() { - return hasProperty('SONATYPE_USERNAME') ? SONATYPE_USERNAME : "" +artifacts { + archives sourcesJar + archives javadocJar } -def getSonatypePassword() { - return hasProperty('SONATYPE_PASSWORD') ? SONATYPE_PASSWORD : "" +signing { + required { gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives } -afterEvaluate { project -> +project.afterEvaluate { uploadArchives { repositories { mavenDeployer { @@ -65,67 +96,44 @@ afterEvaluate { project -> } else { repository(url: mavenLocal().getUrl()) } + configurePom(pom) } } } +} - signing { - required { gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives - } - - if (project.getPlugins().hasPlugin('com.android.library')) { - task install(type: Upload, dependsOn: assemble) { - repositories.mavenInstaller { - configuration = configurations.archives - configurePom(pom) - } - } +def configurePom(pom) { + pom.groupId = POM_GROUP_ID + pom.artifactId = POM_ARTIFACT_ID + pom.version = POM_VERSION - task javadoc(type: Javadoc) { - source = android.sourceSets.main.java.source - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - failOnError false - } + pom.project { + name = POM_NAME + packaging = POM_PACKAGING + url = POM_URL + description = POM_PACKAGING - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir + scm { + url POM_URL + connection POM_GIT_URL + developerConnection POM_GIT_URL } - task sourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.source - } - } else { - install { - repositories.mavenInstaller { - configurePom(pom) + licenses { + license { + name POM_LICENCE_NAME + url POM_LICENCE_URL + distribution POM_LICENCE_DIST } } - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - } - - if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') + developers { + developer { + id POM_DEVELOPER_ID + name POM_DEVELOPER_NAME + email = POM_DEVELOPER_EMAIL } } } - - artifacts { - archives sourcesJar - archives javadocJar - } } \ No newline at end of file diff --git a/config.gradle b/config.gradle index 91e1a06..49f705d 100644 --- a/config.gradle +++ b/config.gradle @@ -6,7 +6,6 @@ ext { android : 'com.android.application', androidLibrary: 'com.android.library', androidMaven : 'com.github.dcendents.android-maven', - bintray : 'com.jfrog.bintray', andServer : 'com.yanzhenjie.andserver' ] diff --git a/gradle.properties b/gradle.properties index 4e44234..3ef1d24 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ android.useAndroidX=true -PROJECT_GROUP=com.yanzhenjie.andserver -PROJECT_VERSION=2.1.9 +POM_GROUP_ID=com.yanzhenjie.andserver +POM_VERSION=2.1.10 POM_DESCRIPTION=Android web server. diff --git a/plugin/build.gradle b/plugin/build.gradle index 36282aa..bce170c 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -14,4 +14,4 @@ dependencies { implementation deps.poet } -apply from: '../bintray.gradle' \ No newline at end of file +apply from: '../central.gradle' \ No newline at end of file diff --git a/processor/build.gradle b/processor/build.gradle index 7018311..dfbfdb4 100644 --- a/processor/build.gradle +++ b/processor/build.gradle @@ -13,4 +13,4 @@ dependencies { implementation deps.apache.collections } -apply from: '../bintray.gradle' \ No newline at end of file +apply from: '../central.gradle' \ No newline at end of file