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
|
apply plugin: 'android-library'
archivesBaseName = 'support-v4'
// create a jar task for the code internal implementation
tasks.create(name: "internalJar", type: Jar) {
baseName "internal_impl"
}
// --------------------------
// TO ADD NEW PLATFORM SPECIFIC CODE, UPDATE THIS:
// create and configure the sourcesets/dependencies for platform-specific code.
// values are: sourceset name, source folder name, api level, previous sourceset.
ext.allSS = []
def baseSS = createApiSourceset('donut', 'donut', '4', null)
def eclairSS = createApiSourceset('eclair', 'eclair', '5', baseSS)
def eclairMr1SS = createApiSourceset('eclairmr1', 'eclair-mr1', '7', eclairSS)
def froyoSS = createApiSourceset('froyo', 'froyo', '8', eclairMr1SS)
def gingerbreadSS = createApiSourceset('gingerbread', 'gingerbread', '9', froyoSS)
def honeycombSS = createApiSourceset('honeycomb', 'honeycomb', '11', gingerbreadSS)
def honeycombMr1SS = createApiSourceset('honeycombmr1', 'honeycomb_mr1', '12', honeycombSS)
def honeycombMr2SS = createApiSourceset('honeycombmr2', 'honeycomb_mr2', '13', honeycombMr1SS)
def icsSS = createApiSourceset('ics', 'ics', '14', honeycombMr2SS)
def icsMr1SS = createApiSourceset('icsmr1', 'ics-mr1', '15', icsSS)
def jbSS = createApiSourceset('jellybean', 'jellybean', '16', icsMr1SS)
def jbMr1SS = createApiSourceset('jellybeanmr1', 'jellybean-mr1', '17', jbSS)
def jbMr2SS = createApiSourceset('jellybeanmr2', 'jellybean-mr2', '18', jbMr1SS)
def kitkatSS = createApiSourceset('kitkat', 'kitkat', '19', jbMr2SS)
def api20SS = createApiSourceset('api20', 'api20', '20', kitkatSS)
def api21SS = createApiSourceset('api21', 'api21', '21', api20SS)
def api22SS = createApiSourceset('api22', 'api22', '22', api21SS)
def api23SS = createApiSourceset('api23', 'api23', 'current', api22SS)
def createApiSourceset(String name, String folder, String apiLevel, SourceSet previousSource) {
def sourceSet = sourceSets.create(name)
sourceSet.java.srcDirs = [folder]
def configName = sourceSet.getCompileConfigurationName()
project.getDependencies().add(configName, getAndroidPrebuilt(apiLevel))
if (previousSource != null) {
setupDependencies(configName, previousSource)
}
ext.allSS.add(sourceSet)
internalJar.from sourceSet.output
return sourceSet
}
def setupDependencies(String configName, SourceSet previousSourceSet) {
project.getDependencies().add(configName, previousSourceSet.output)
project.getDependencies().add(configName, previousSourceSet.compileClasspath)
}
dependencies {
compile project(':support-annotations')
donutCompile project(':support-annotations')
// add the internal implementation as a dependency.
// this is not enough to make the regular compileJava task
// depend on the generation of this jar. This is done below
// when manipulating the libraryVariants.
compile files(internalJar.archivePath)
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
testCompile 'junit:junit:4.12'
}
android {
compileSdkVersion 4
defaultConfig {
minSdkVersion 4
// TODO: get target from branch
//targetSdkVersion 19
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets {
main.manifest.srcFile 'AndroidManifest.xml'
main.java.srcDirs = ['java']
main.aidl.srcDirs = ['java']
androidTest.setRoot('tests')
androidTest.java.srcDir 'tests/java'
androidTest.res.srcDir 'tests/res'
androidTest.manifest.srcFile 'tests/AndroidManifest.xml'
}
lintOptions {
// TODO: fix errors and reenable.
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests.returnDefaultValues = true
}
}
android.libraryVariants.all { variant ->
variant.javaCompile.dependsOn internalJar
def name = variant.buildType.name
if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
return; // Skip debug builds.
}
def suffix = name.capitalize()
def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
dependsOn variant.javaCompile
from variant.javaCompile.destinationDir
from 'LICENSE.txt'
}
def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
source android.sourceSets.main.java
classpath = files(variant.javaCompile.classpath.files) + files(
"${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
}
def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
exclude('android/content/pm/**')
exclude('android/service/media/**')
}
project.ext.allSS.each { ss ->
javadocTask.source ss.java
sourcesJarTask.from ss.java.srcDirs
}
artifacts.add('archives', javadocJarTask);
artifacts.add('archives', sourcesJarTask);
}
// TODO make this generic for all projects
afterEvaluate {
def originalTask = tasks['packageDebugAndroidTest']
tasks['assembleDebugAndroidTest'].doLast {
copy {
from(originalTask.outputFile)
into(rootProject.ext.testApkDistOut)
}
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri(rootProject.ext.supportRepoOut)) {
}
pom.project {
name 'Android Support Library v4'
description "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 4 or later."
url 'http://developer.android.com/tools/extras/support-library.html'
inceptionYear '2011'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url "http://source.android.com"
connection "scm:git:https://android.googlesource.com/platform/frameworks/support"
}
developers {
developer {
name 'The Android Open Source Project'
}
}
}
}
}
}
|