Skip to content

Commit

Permalink
Develop the new release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
yanzhenjie committed Jul 23, 2020
1 parent 7c05e15 commit b73bb7a
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 56 deletions.
5 changes: 3 additions & 2 deletions annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apply plugin: plugin.javaLibrary
apply from: '../publish.gradle'

compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

apply from: '../bintray.gradle'
2 changes: 1 addition & 1 deletion annotation/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
POM_NAME=AndServer
POM_NAME=andserver-annotation
POM_ARTIFACT_ID=annotation
POM_PACKAGING=jar
16 changes: 12 additions & 4 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: plugin.androidLibrary
apply from: '../publish.gradle'

android {
compileSdkVersion androidBuild.compileSdkVersion
Expand All @@ -8,15 +7,22 @@ android {
defaultConfig {
minSdkVersion androidBuild.libraryMinSdkVersion
targetSdkVersion androidBuild.libraryTargetSdkVersion
versionCode androidBuild.versionCode
versionName androidBuild.versionName
consumerProguardFiles 'proguard-rules.txt'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
buildConfigField "java.lang.String", "PROJECT_VERSION", "\"${PROJECT_VERSION}\""
}
debug {
buildConfigField "java.lang.String", "PROJECT_VERSION", "\"${PROJECT_VERSION}\""
}
}
}

dependencies {
Expand All @@ -25,4 +31,6 @@ dependencies {
implementation deps.apache.httpcore
implementation deps.apache.fileupload
compileOnly deps.android.annotation
}
}

apply from: '../bintray.gradle'
2 changes: 1 addition & 1 deletion api/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
POM_NAME=AndServer
POM_NAME=andserver-api
POM_ARTIFACT_ID=api
POM_PACKAGING=aar
2 changes: 1 addition & 1 deletion api/src/main/java/com/yanzhenjie/andserver/AndServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class AndServer {

public static final String TAG = "AndServer";
public static final String INFO = String.format("AndServer/%1$s", BuildConfig.VERSION_NAME);
public static final String INFO = String.format("AndServer/%1$s", BuildConfig.PROJECT_VERSION);

/**
* Create a builder for the web server.
Expand Down
133 changes: 133 additions & 0 deletions bintray.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
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())
}
}
}
}

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 {
packaging POM_PACKAGING
name POM_NAME
url POM_URL
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
}
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ buildscript {

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.2'
}
}
Expand Down
31 changes: 15 additions & 16 deletions publish.gradle → central.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ version = PROJECT_VERSION
def toRemote = project.hasProperty('toRemote') ? Boolean.valueOf("${toRemote}") : false
println("publish to remote repository:${toRemote}")

def getUsername() {
return hasProperty('USERNAME') ? USERNAME : ""
}

def getPassword() {
return hasProperty('PASSWORD') ? PASSWORD : ""
}

def configurePom(pom) {
pom.groupId = PROJECT_GROUP
pom.artifactId = POM_ARTIFACT_ID
Expand All @@ -27,9 +19,9 @@ def configurePom(pom) {
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
url POM_URL
connection POM_GIT_URL
developerConnection POM_GIT_URL
}

licenses {
Expand All @@ -49,6 +41,14 @@ def configurePom(pom) {
}
}

def getSonatypeUserName() {
return hasProperty('SONATYPE_USERNAME') ? SONATYPE_USERNAME : ""
}

def getSonatypePassword() {
return hasProperty('SONATYPE_PASSWORD') ? SONATYPE_PASSWORD : ""
}

afterEvaluate { project ->
uploadArchives {
repositories {
Expand All @@ -57,22 +57,21 @@ afterEvaluate { project ->

if (toRemote) {
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: getUsername(), password: getPassword())
authentication(userName: getSonatypeUserName(), password: getSonatypePassword())
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: getUsername(), password: getPassword())
authentication(userName: getSonatypeUserName(), password: getSonatypePassword())
}
configurePom(pom)
} else {
repository(url: mavenLocal().getUrl())
}

configurePom(pom)
}
}
}

signing {
required { !version.concat('SNAPSHOT') && gradle.taskGraph.hasTask("uploadArchives") }
required { toRemote && !version.concat('SNAPSHOT') && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

Expand Down
7 changes: 3 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ PROJECT_VERSION=2.1.2
POM_DESCRIPTION=Android web server.

POM_URL=https://github.com/yanzhenjie/AndServer/
POM_SCM_URL=https://github.com/yanzhenjie/AndServer/
POM_SCM_CONNECTION=scm:git:git://github.com/yanzhenjie/AndServer.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/yanzhenjie/AndServer.git
POM_GIT_URL=git://github.com/yanzhenjie/AndServer.git

POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=yanzhenjie
POM_DEVELOPER_NAME=Zhenjie Yan
POM_DEVELOPER_NAME=Zhenjie Yan
POM_DEVELOPER_EMAIL[email protected]
5 changes: 3 additions & 2 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: plugin.javaLibrary
apply plugin: plugin.javaPlugin
apply from: '../publish.gradle'

compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -13,4 +12,6 @@ dependencies {

implementation deps.android.plugin
implementation deps.poet
}
}

apply from: '../bintray.gradle'
2 changes: 1 addition & 1 deletion plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
POM_NAME=AndServer
POM_NAME=andserver-plugin
POM_ARTIFACT_ID=plugin
POM_PACKAGING=jar
5 changes: 3 additions & 2 deletions processor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: plugin.javaLibrary
apply from: '../publish.gradle'

compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -12,4 +11,6 @@ dependencies {
implementation deps.poet
implementation deps.apache.lang
implementation deps.apache.collections
}
}

apply from: '../bintray.gradle'
2 changes: 1 addition & 1 deletion processor/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
POM_NAME=AndServer
POM_NAME=andserver-processor
POM_ARTIFACT_ID=processor
POM_PACKAGING=jar
3 changes: 0 additions & 3 deletions publish.sh

This file was deleted.

18 changes: 0 additions & 18 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,6 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
debug {
debuggable true
zipAlignEnabled false
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

release {
debuggable false
zipAlignEnabled true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
Expand Down

0 comments on commit b73bb7a

Please sign in to comment.