From 00e3ce323132ad7a0d2515e385113e5a2ce8121a Mon Sep 17 00:00:00 2001 From: Simon Vig Therkildsen Date: Tue, 29 Apr 2014 18:34:32 +0200 Subject: [PATCH] Support both android and java projects. --- gradle-mvn-push.gradle | 120 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 107 insertions(+), 13 deletions(-) diff --git a/gradle-mvn-push.gradle b/gradle-mvn-push.gradle index 82f5317..849b7ec 100644 --- a/gradle-mvn-push.gradle +++ b/gradle-mvn-push.gradle @@ -17,6 +17,9 @@ apply plugin: 'maven' apply plugin: 'signing' +version = VERSION_NAME +group = GROUP + def isReleaseBuild() { return VERSION_NAME.contains("SNAPSHOT") == false } @@ -92,23 +95,114 @@ afterEvaluate { project -> sign configurations.archives } - task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.allJava - classpath += project.files(android.plugin.getRuntimeJarList().join(File.pathSeparator)) - } + if (project.getPlugins().hasPlugin('android') || project.getPlugins().hasPlugin('android-library')) { + task install(type: Upload, dependsOn: assemble) { + repositories.mavenInstaller { + configuration = configurations.archives - task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - classifier = 'javadoc' - from androidJavadocs.destinationDir - } + 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 androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.allJava + classpath += project.files(android.plugin.getRuntimeJarList().join(File.pathSeparator)) + } + + task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + classifier = 'javadoc' + from androidJavadocs.destinationDir + } + + task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.allSource + } + } 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 + } - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.allSource + 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 + } } artifacts { - archives androidSourcesJar - archives androidJavadocsJar + if (project.getPlugins().hasPlugin('android') || project.getPlugins().hasPlugin('android-library')) { + archives androidSourcesJar + archives androidJavadocsJar + } else { + archives sourcesJar + archives javadocJar + } } }