f9516fd73d5c762427c13b7b67775de9ae441997
[android/platform/tools/build.git] / builder / build.gradle
1 apply plugin: 'java'
2 apply plugin: 'maven'
3 apply plugin: 'signing'
4
5 project.ext.baseAndroidVersion = "22.0-SNAPSHOT"
6
7 dependencies {
8     compile "com.android.tools.sdk:sdklib:$project.ext.baseAndroidVersion"
9     compile "com.android.tools:sdk-common:$project.ext.baseAndroidVersion"
10     compile "com.android.tools.build:manifest-merger:$project.ext.baseAndroidVersion"
11     compile "com.android.tools:ddmlib:$project.ext.baseAndroidVersion"
12
13     testCompile 'junit:junit:3.8.1'
14 }
15
16 def getVersion() {
17     if (project.has("release")) {
18         return project.ext.baseVersion
19     }
20
21     return project.ext.baseVersion + '-SNAPSHOT'
22 }
23
24 version = getVersion()
25 archivesBaseName = 'builder'
26
27 jar {
28     from { configurations.runtime.collect { it.directory ? it : zipTree(it) } }
29 }
30
31 configure(install.repositories.mavenInstaller) {
32     // Discard all the dependencies from the POM, as they are packaged in the JAR.
33     pom.scopeMappings.mappings.clear()
34 }
35
36 task publishLocal(type: Upload) {
37     configuration = configurations.archives
38     repositories {
39         mavenDeployer {
40             repository(url: uri("$rootDir/repo"))
41
42             // Discard all the dependencies from the POM, as they are packaged in the JAR.
43             pom.scopeMappings.mappings.clear()
44         }
45     }
46 }
47
48 project.ext.sonatypeUsername = project.hasProperty('sonatypeUsername') ? sonatypeUsername : ""
49 project.ext.sonatypePassword = project.hasProperty('sonatypePassword') ? sonatypePassword : ""
50
51 uploadArchives {
52     repositories {
53         mavenDeployer {
54             beforeDeployment { MavenDeployment deployment ->
55                 if (!project.has("release")) {
56                     throw new StopExecutionException("uploadArchives must be called with the release.gradle init script")
57                 }
58
59                 if (ext.sonatypeUsername.length() == 0 || ext.sonatypePassword.length() == 0) {
60                     throw new StopExecutionException("uploadArchives cannot be called without sonatype username and password")
61                 }
62
63                 signing.signPom(deployment)
64             }
65
66             repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
67                 authentication(userName: project.ext.sonatypeUsername, password: project.ext.sonatypePassword)
68             }
69
70             // Discard all the dependencies from the POM, as they are packaged in the JAR.
71             pom.scopeMappings.mappings.clear()
72
73             pom.project {
74                 name 'Android Builder library'
75                 description 'library to build Android applications.'
76                 url 'http://tools.android.com'
77                 inceptionYear '2007'
78
79                 licenses {
80                     license {
81                         name 'The Apache Software License, Version 2.0'
82                         url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
83                         distribution 'repo'
84                     }
85                 }
86
87                 scm {
88                     url "https://android.googlesource.com/platform/tools/build"
89                     connection "git://android.googlesource.com/platform/tools/build.git"
90                 }
91                 developers {
92                     developer {
93                         name 'The Android Open Source Project'
94                     }
95                 }
96             }
97         }
98     }
99 }
100
101
102 // custom tasks for creating source/javadoc jars
103 task sourcesJar(type: Jar, dependsOn:classes) {
104     classifier = 'sources'
105     from sourceSets.main.allSource
106 }
107
108 javadoc {
109     exclude               "**/internal/**"
110     options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
111
112     title                 "Android Builder"
113 }
114
115 task javadocJar(type: Jar, dependsOn:javadoc) {
116     classifier         'javadoc'
117     from               javadoc.destinationDir
118 }
119  
120 // add javadoc/source jar tasks as artifacts
121 artifacts {
122     archives jar
123     archives sourcesJar
124     archives javadocJar
125 }
126
127 signing {
128     required { project.has("release") && gradle.taskGraph.hasTask("uploadArchives") }
129     sign configurations.archives
130 }