update gradle-mvn-push script
MODIFY
gradle/gradle-mvn-push.gradle
gradle/gradle-mvn-push.gradle
apply plugin: 'maven'
apply plugin: 'signing'
+version = VERSION_NAME
+group = GROUP
+
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('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}
@@ -39,10 +52,10 @@ afterEvaluate { project ->
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
- repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
+ repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
- snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
+ snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
@@ -82,20 +95,51 @@ afterEvaluate { project ->
sign configurations.archives
}
- task androidJavadocs(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
- classpath += project.android.libraryVariants.toList().first().javaCompile.classpath
+ if (project.getPlugins().hasPlugin('com.android.application') ||
+ project.getPlugins().hasPlugin('com.android.library')) {
+ task install(type: Upload, dependsOn: assemble) {
+ repositories.mavenInstaller {
+ configuration = configurations.archives
+
+ pom.groupId = GROUP
+ pom.artifactId = POM_ARTIFACT_ID
+ pom.version = VERSION_NAME
+
+ 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
}
- if (JavaVersion.current().isJava8Compatible()) {
- allprojects {
- tasks.withType(Javadoc) {
- options.addStringOption('Xdoclint:none', '-quiet')
+ licenses {
+ license {
+ name POM_LICENCE_NAME
+ url POM_LICENCE_URL
+ distribution POM_LICENCE_DIST
+ }
+ }
+
+ developers {
+ developer {
+ id POM_DEVELOPER_ID
+ name POM_DEVELOPER_NAME
+ }
+ }
}
}
}
+ task androidJavadocs(type: Javadoc) {
+ source = android.sourceSets.main.java.source
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+ }
+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
@@ -103,11 +147,72 @@ afterEvaluate { project ->
task androidSourcesJar(type: Jar) {
classifier = 'sources'
- from android.sourceSets.main.java.sourceFiles
+ from android.sourceSets.main.java.source
+ }
+ } else {
+ install {
+ repositories.mavenInstaller {
+ pom.groupId = GROUP
+ pom.artifactId = POM_ARTIFACT_ID
+ pom.version = VERSION_NAME
+
+ 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
+ }
+ }
+ }
+ }
+ }
+
+ 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 {
+ if (project.getPlugins().hasPlugin('com.android.application') ||
+ project.getPlugins().hasPlugin('com.android.library')) {
archives androidSourcesJar
archives androidJavadocsJar
+ } else {
+ archives sourcesJar
+ archives javadocJar
+ }
}
}
\ No newline at end of file

update gradle-mvn-push script