aboutsummaryrefslogtreecommitdiff
path: root/gradle/build.gradle
blob: f83bc7a9b9b528776f6190827139ecf956ca8288 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'clone-artifacts'

configurations {
    gradleApi
    compile.extendsFrom gradleApi
    gradleApi.extendsFrom groovy
}

sourceSets {
    main {
        groovy.srcDirs 'src/main/groovy', 'src/fromGradle/groovy'
        resources.srcDirs 'src/main/resources', 'src/fromGradle/resources'
    }
    buildTest {
        groovy.srcDir file('src/build-test/groovy')
        resources.srcDir file('src/build-test/resources')
    }
    deviceTest {
        groovy.srcDir file('src/device-test/groovy')
        resources.srcDir file('src/device-test/resources')
    }
}

dependencies {
    gradleApi gradleApi()
    groovy localGroovy()
    compile project(':builder')

    compile "com.android.tools:sdklib:$project.ext.baseAndroidVersion"
    compile "com.android.tools:sdk-common:$project.ext.baseAndroidVersion"
    compile "com.android.tools:common:$project.ext.baseAndroidVersion"

    compile "com.android.tools.lint:lint:$project.ext.baseAndroidVersion"
    compile 'net.sf.proguard:proguard-gradle:4.10'

    testCompile 'junit:junit:3.8.1'

    buildTestCompile sourceSets.main.output
    buildTestCompile sourceSets.test.output
    buildTestCompile configurations.testCompile
    buildTestCompile configurations.testRuntime

    deviceTestCompile sourceSets.main.output
    deviceTestCompile sourceSets.test.output
    deviceTestCompile sourceSets.buildTest.output
    deviceTestCompile configurations.testCompile
    deviceTestCompile configurations.testRuntime
}

// configuration for dependencies provided by the runtime,
// in this case proguard.
configurations{
    provided
}

dependencies{
    provided 'net.sf.proguard:proguard-gradle:4.10'
}

//Include provided for compilation
sourceSets.main.compileClasspath += configurations.provided


idea {
    module {
        testSourceDirs += files('src/build-test/groovy', 'src/device-test/groovy').files

        scopes.COMPILE.plus += configurations.provided
    }
}

def getVersion() {
    if (project.has("release")) {
        return project.ext.baseVersion
    }

    return project.ext.baseVersion + '-SNAPSHOT'
}

version = getVersion()
archivesBaseName = 'gradle'
jar.manifest.attributes("Plugin-Version": version)

task publishLocal(type: Upload) {
    configuration = configurations.archives
    repositories {
        mavenDeployer {
            repository(url: uri(rootProject.ext.localRepo))
        }
    }
}
publishLocal.dependsOn ':builder:publishLocal'

task buildTest(type: Test, dependsOn: publishLocal) {
    testClassesDir = sourceSets.buildTest.output.classesDir
    classpath = sourceSets.buildTest.runtimeClasspath
    description = "Runs the project build tests. This requires an SDK either from the Android source tree, under out/..., or an env var ANDROID_HOME."
    group = "verification"
    systemProperties['jar.path'] = jar.archivePath
}

task deviceTest(type: Test, dependsOn: publishLocal) {
    testClassesDir = sourceSets.deviceTest.output.classesDir
    classpath = sourceSets.deviceTest.runtimeClasspath
    description = "Runs the device tests. This requires a device."
    group = "verification"
    systemProperties['jar.path'] = jar.archivePath
}

check.dependsOn buildTest

project.ext.sonatypeUsername = project.hasProperty('sonatypeUsername') ? sonatypeUsername : ""
project.ext.sonatypePassword = project.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)
            }

            pom.project {
                name 'Gradle Plug-in for Android'
                description 'Gradle plug-in 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'
                    }
                }
            }
        }
    }
}

// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn:classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

groovydoc {
    exclude     "**/internal/**"
    includePrivate false

    docTitle "Gradle Plugin for Android"
    header ""
    footer "Copyright (C) 2012 The Android Open Source Project"
    overview ""
}

task javadocJar(type: Jar, dependsOn:groovydoc) {
    classifier  'javadoc'
    from        groovydoc.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
}