| plugins { |
| id 'com.android.tools.javadoc' |
| id 'maven-publish' |
| id 'signing' |
| } |
| |
| // Disable test-fixtures publishing to Maven |
| project.plugins.withId('java-test-fixtures') { |
| components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { |
| skip() |
| } |
| components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { |
| skip() |
| } |
| } |
| |
| if (!project.hasProperty("release")) { |
| components.java.withVariantsFromConfiguration(configurations["sourcesElements"]) { |
| skip() |
| } |
| components.java.withVariantsFromConfiguration(configurations["javadocElements"]) { |
| skip() |
| } |
| } |
| |
| project.ext.publishJavaComponent = true |
| // When java-gradle-plugin is applied, it publishes both markers and the plugin, so we don't |
| // need to do anything. |
| project.plugins.withId('java-gradle-plugin') { |
| project.ext.publishJavaComponent = false |
| } |
| |
| // replace the arbitrarily generated buildId in module metadata to the one from the busytown |
| // Workaround for https://github.com/gradle/gradle/issues/11717 |
| project.tasks.withType(GenerateModuleMetadata).configureEach { |
| def buildId = project.providers.environmentVariable("BUILD_NUMBER").orElse("0") |
| it.inputs.property("BUILD_NUMBER", buildId).optional(true) |
| doLast { |
| def metadata = outputFile.asFile.get() |
| def text = metadata.getText() |
| def pattern = java.util.regex.Pattern.compile("\"buildId\":.*") |
| def m = pattern.matcher(text) |
| if(m.find()) { |
| metadata.write(text.replace(m.group(0), "\"buildId\": \"${buildId.get()}\"")) |
| } |
| } |
| } |
| |
| afterEvaluate { |
| publishing { |
| repositories { |
| maven { |
| name = "local" |
| url = uri("$rootProject.ext.localRepo") |
| } |
| } |
| publications { |
| withType(MavenPublication) { |
| def pomDescription = project.ext.pomDesc |
| def pomGroupId = groupId |
| def pomArtifactId = artifactId |
| pom.withXml { |
| asNode().appendNode('description', pomDescription) |
| asNode().appendNode('url', 'https://developer.android.com/studio/build') |
| asNode().appendNode('name', pomGroupId + '.' + pomArtifactId) |
| |
| Node license = asNode().appendNode('licenses').appendNode('license') |
| license.appendNode('name', 'The Apache Software License, Version 2.0') |
| license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt') |
| license.appendNode('distribution', 'repo') |
| |
| asNode().appendNode('developers') |
| .appendNode('developer') |
| .appendNode('name', 'The Android Open Source Project') |
| |
| Node scm = asNode().appendNode('scm') |
| scm.appendNode('connection', |
| 'git://android.googlesource.com/platform/tools/base.git') |
| scm.appendNode('url', 'https://android.googlesource.com/platform/tools/base') |
| } |
| } |
| |
| if (project.ext.publishJavaComponent) { |
| mavenJava(MavenPublication) { |
| from components.java |
| } |
| } |
| } |
| } |
| } |