Skip to content

Commit

Permalink
updated uploading script
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriel committed Nov 10, 2016
1 parent cfb9d24 commit 6c402f6
Showing 1 changed file with 19 additions and 59 deletions.
78 changes: 19 additions & 59 deletions gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
//return VERSION_NAME.contains("SNAPSHOT") == false
return hasProperty('SNAPSHOT')? Boolean.valueOf(SNAPSHOT): false
}

def getReleaseRepositoryUrl() {
Expand All @@ -31,6 +32,14 @@ def getSnapshotRepositoryUrl() {
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getLocalRepositoryUrl() {
return hasProperty('LOCAL_MVN_REPO') ? LOCAL_MVN_REPO: ''
}

def uploadToLocalRepo() {
return hasProperty('UPLOAD_TO_LOCAL') ? Boolean.valueOf(UPLOAD_TO_LOCAL) : false
}

def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}
Expand All @@ -49,9 +58,16 @@ afterEvaluate { project ->
pom.artifactId = POM_ARTIFACT_ID
pom.version = rootProject.mavenVersionName

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
if (uploadToLocalRepo()) {
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
} else {
repository(url: getLocalRepositoryUrl()) {
authentication(userName: maven_user, password: maven_password)
}
}

snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
Expand Down Expand Up @@ -111,60 +127,4 @@ afterEvaluate { project ->
archives androidSourcesJar
//archives androidJavadocsJar
}

// /**
// * Upload to local maven repository
// * if it is needed, please add following properties:
// * - LOCAL_MVN_REPO: local repo url
// * - maven_user: local repo user name
// * - maven_password: local repo password
// */
// task uploadExternal(type: Upload) {
// def localRepo = properties.get("LOCAL_MVN_REPO")
// def localRepoUser = properties.get("maven_user")
// def localRepoPwd = properties.get("maven_password")
//
// if (null != localRepo) {
// uploadDescriptor = true
// repositories.mavenDeployer {
// beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
//
// pom.groupId = GROUP
// pom.artifactId = POM_ARTIFACT_ID
// pom.version = rootProject.mavenVersionName
// // Add other pom properties here if you want (developer details / licenses)
// repository(url: localRepo) {
// authentication(userName: localRepoUser, password: localRepoPwd)
// }
//
// 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
// }
// }
// }
// }
// }
// }
}

0 comments on commit 6c402f6

Please sign in to comment.