Created
November 26, 2016 04:04
-
-
Save xdyuchen/9ac4286761e488a871f5524d708082c2 to your computer and use it in GitHub Desktop.
gradle maven push
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'maven' | |
apply plugin: 'signing' | |
def isReleaseBuild() { | |
return VERSION_NAME.contains("SNAPSHOT") == false | |
} | |
def getReleaseRepositoryUrl() { | |
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL | |
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/" | |
} | |
def getSnapshotRepositoryUrl() { | |
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL | |
: "https://oss.sonatype.org/content/repositories/snapshots/" | |
} | |
def getRepositoryUsername() { | |
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : "your nexus repo name" | |
} | |
def getRepositoryPassword() { | |
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : "your nexus repo password" | |
} | |
afterEvaluate { project -> | |
uploadArchives { | |
repositories { | |
mavenDeployer { | |
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | |
pom.groupId = GROUP | |
pom.artifactId = POM_ARTIFACT_ID | |
pom.version = VERSION_NAME | |
repository(url: getReleaseRepositoryUrl()) { | |
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) | |
} | |
snapshotRepository(url: getSnapshotRepositoryUrl()) { | |
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) | |
} | |
pom.project { | |
name POM_NAME | |
packaging POM_PACKAGING | |
description POM_DESCRIPTION | |
url POM_URL | |
scm { | |
url POM_SCM_URL | |
connection POM_SCM_CONNECTION | |
developerConnection POM_SCM_DEV_CONNECTION | |
} | |
licenses { | |
license { | |
name POM_LICENCE_NAME | |
url POM_LICENCE_URL | |
distribution POM_LICENCE_DIST | |
} | |
} | |
developers { | |
developer { | |
id POM_DEVELOPER_ID | |
name POM_DEVELOPER_NAME | |
} | |
} | |
} | |
} | |
} | |
} | |
signing { | |
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } | |
sign configurations.archives | |
} | |
task androidJavadocs(type: Javadoc) { | |
source = android.sourceSets.main.java.srcDirs | |
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" | |
classpath += files(ext.androidJar) | |
} | |
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { | |
classifier = 'javadoc' | |
from androidJavadocs.destinationDir | |
} | |
task androidSourcesJar(type: Jar) { | |
classifier = 'sources' | |
from android.sourceSets.main.java.sourceFiles | |
} | |
if (JavaVersion.current().isJava8Compatible()) { | |
allprojects { | |
tasks.withType(Javadoc) { | |
options.addStringOption('Xdoclint:none', '-quiet') | |
} | |
} | |
} | |
artifacts { | |
archives androidSourcesJar | |
archives androidJavadocsJar | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Signing Plugin Config | |
signing.keyId= | |
signing.password= | |
signing.secretKeyRingFile= | |
# Project Info | |
GROUP= | |
VERSION_NAME= | |
POM_PACKAGING= | |
POM_DESCRIPTION= | |
POM_URL= | |
POM_SCM_URL= | |
POM_SCM_CONNECTION= | |
POM_SCM_DEV_CONNECTION= | |
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= | |
POM_DEVELOPER_NAME= |
POM_DEVELOPER_NAME POM_DEVELOPER_ID 这两个分别代表的什么呀
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
POM_DEVELOPER_ID