blob: 7087a6a3f6266990f6582a66a958e882d38b08e1 [file] [log] [blame]
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
project.ext.baseAndroidVersion = "22.0-SNAPSHOT"
configurations {
fakeMaven
}
dependencies {
compile "com.android.tools:sdklib:$project.ext.baseAndroidVersion"
compile "com.android.tools:sdk-common:$project.ext.baseAndroidVersion"
compile "com.android.tools.build:manifest-merger:$project.ext.baseAndroidVersion"
compile "com.android.tools.ddms:ddmlib:$project.ext.baseAndroidVersion"
compile 'org.bouncycastle:bcpkix-jdk15on:1.48'
testCompile 'junit:junit:3.8.1'
}
def getVersion() {
if (project.has("release")) {
return project.ext.baseVersion
}
return project.ext.baseVersion + '-SNAPSHOT'
}
version = getVersion()
archivesBaseName = 'builder'
def getInternalDependencies() {
def list = []
Set<ResolvedArtifact> artifacts = configurations.runtime.resolvedConfiguration.resolvedArtifacts
for (ResolvedArtifact artifact : artifacts) {
def group = artifact.moduleVersion.id.group
if (group.startsWith('com.android.tools') || group == 'base' || group == 'swt') {
list << artifact.file
}
}
list
}
jar {
// gather the local dependencies and package them in the builder jar.
def internalDep = getInternalDependencies()
from { internalDep.collect { it.directory ? it : zipTree(it) } }
}
// add the external dependencies to the fakeMaven configuration.
task mavenSetup << {
Set<ResolvedArtifact> artifacts = configurations.runtime.resolvedConfiguration.resolvedArtifacts
for (ResolvedArtifact artifact : artifacts) {
def group = artifact.moduleVersion.id.group
if (!(group.startsWith('com.android.tools') || group == 'base' || group == 'swt')) {
def id = artifact.moduleVersion.id
project.dependencies {
fakeMaven "${id.group}:${id.name}:${id.version}"
}
}
}
}
configure(install.repositories.mavenInstaller) {
// Discard all the dependencies from the POM, as they are packaged in the JAR.
pom.scopeMappings.mappings.clear()
// add the fake ones from fakeMaven
pom.scopeMappings.addMapping(300, configurations.fakeMaven, "compile")
}
task publishLocal(type: Upload, dependsOn: mavenSetup) {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: uri("$rootDir/repo"))
// Discard all the dependencies from the POM, as they are packaged in the JAR.
pom.scopeMappings.mappings.clear()
// add the fake ones from fakeMaven
pom.scopeMappings.addMapping(300, configurations.fakeMaven, "compile")
}
}
}
project.ext.sonatypeUsername = hasProperty('sonatypeUsername') ? sonatypeUsername : ""
project.ext.sonatypePassword = hasProperty('sonatypePassword') ? sonatypePassword : ""
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment ->
if (!project.has("release")) {
throw new StopExecutionException("uploadArchives must be called with the release.gradle init script")
}
if (project.ext.sonatypeUsername.length() == 0 || project.ext.sonatypePassword.length() == 0) {
throw new StopExecutionException("uploadArchives cannot be called without sonatype username and password")
}
signing.signPom(deployment)
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project.ext.sonatypeUsername, password: project.ext.sonatypePassword)
}
// Discard all the dependencies from the POM, as they are packaged in the JAR.
pom.scopeMappings.mappings.clear()
pom.project {
name 'Android Builder library'
description 'library to build Android applications.'
url 'http://tools.android.com'
inceptionYear '2007'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url "https://android.googlesource.com/platform/tools/build"
connection "git://android.googlesource.com/platform/tools/build.git"
}
developers {
developer {
name 'The Android Open Source Project'
}
}
}
}
}
}
uploadArchives.dependsOn mavenSetup
// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
javadoc {
exclude "**/internal/**"
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
title "Android Builder"
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier 'javadoc'
from javadoc.destinationDir
}
// add javadoc/source jar tasks as artifacts
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
signing {
required { project.has("release") && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}