blob: 52f5b6e1ee4229941590a1e8c2329f5355ef3d25 [file] [log] [blame]
Griff Hazen43227bb2014-05-28 07:59:33 -07001apply plugin: 'android-library'
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -08002archivesBaseName = 'support-v4'
3
Xavier Ducrohet15474b92014-03-21 17:11:38 -07004// --------------------------
5// TO ADD NEW PLATFORM SPECIFIC CODE, UPDATE THIS:
6// create and configure the sourcesets/dependencies for platform-specific code.
7// values are: sourceset name, source folder name, api level, previous sourceset.
Griff Hazen43227bb2014-05-28 07:59:33 -07008
9ext.allSS = []
10
11def baseSS = createApiSourceset('donut', 'donut', '4', null)
12def eclairSS = createApiSourceset('eclair', 'eclair', '5', baseSS)
Xavier Ducrohet15474b92014-03-21 17:11:38 -070013def eclairMr1SS = createApiSourceset('eclairmr1', 'eclair-mr1', '7', eclairSS)
14def froyoSS = createApiSourceset('froyo', 'froyo', '8', eclairMr1SS)
15def gingerbreadSS = createApiSourceset('gingerbread', 'gingerbread', '9', froyoSS)
16def honeycombSS = createApiSourceset('honeycomb', 'honeycomb', '11', gingerbreadSS)
17def honeycombMr2SS = createApiSourceset('honeycombmr2', 'honeycomb_mr2', '13', honeycombSS)
18def icsSS = createApiSourceset('ics', 'ics', '14', honeycombMr2SS)
19def icsMr1SS = createApiSourceset('icsmr1', 'ics-mr1', '15', icsSS)
20def jbSS = createApiSourceset('jellybean', 'jellybean', '16', icsMr1SS)
21def jbMr1SS = createApiSourceset('jellybeanmr1', 'jellybean-mr1', '17', jbSS)
22def jbMr2SS = createApiSourceset('jellybeanmr2', 'jellybean-mr2', '18', jbMr1SS)
23def kitkatSS = createApiSourceset('kitkat', 'kitkat', '19', jbMr2SS)
Xavier Ducrohet261f67b2014-03-21 17:11:38 -070024def api20SS = createApiSourceset('api20', 'api20', 'current', kitkatSS)
Griff Hazen652adc22014-05-28 08:42:19 -070025def api21SS = createApiSourceset('api21', 'api21', 'current', api20SS)
Xavier Ducrohet855a9222014-01-02 19:00:43 -080026
Xavier Ducrohet15474b92014-03-21 17:11:38 -070027
28def createApiSourceset(String name, String folder, String apiLevel, SourceSet previousSource) {
29 def sourceSet = sourceSets.create(name)
30 sourceSet.java.srcDirs = [folder]
31
32 def configName = sourceSet.getCompileConfigurationName()
33
34 project.getDependencies().add(configName, getAndroidPrebuilt(apiLevel))
35 if (previousSource != null) {
36 setupDependencies(configName, previousSource)
37 }
Griff Hazen43227bb2014-05-28 07:59:33 -070038 ext.allSS.add(sourceSet)
Xavier Ducrohet15474b92014-03-21 17:11:38 -070039 return sourceSet
40}
41
42def setupDependencies(String configName, SourceSet previousSourceSet) {
43 project.getDependencies().add(configName, previousSourceSet.output)
44 project.getDependencies().add(configName, previousSourceSet.compileClasspath)
45}
46
Griff Hazen43227bb2014-05-28 07:59:33 -070047// create a jar task for the code above
48tasks.create(name: "internalJar", type: Jar) {
49 baseName "internal_impl"
50}
51
52ext.allSS.each { ss ->
53 internalJar.from ss.output
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080054}
55
56dependencies {
Tor Norbye05568b72014-03-20 19:19:52 -070057 compile project(':support-annotations')
Griff Hazen43227bb2014-05-28 07:59:33 -070058
59 // add the internal implementation as a dependency.
60 // this is not enough to make the regular compileJava task
61 // depend on the generation of this jar. This is done below
62 // when manipulating the libraryVariants.
63 compile files(internalJar.archivePath)
64}
65
66android {
67 compileSdkVersion 4
68 buildToolsVersion "19.0.1"
69
70 defaultConfig {
71 minSdkVersion 4
72 // TODO: get target from branch
73 //targetSdkVersion 19
74 }
75
76 sourceSets {
77 main.manifest.srcFile 'AndroidManifest.xml'
78 main.java.srcDirs = ['java']
79 main.aidl.srcDirs = ['java']
80
81 androidTest.setRoot('tests')
82 androidTest.java.srcDir 'tests/java'
83 }
84
85 lintOptions {
86 // TODO: fix errors and reenable.
87 abortOnError false
88 }
89}
90
91android.libraryVariants.all { variant ->
92 variant.javaCompile.dependsOn internalJar
93
94 def name = variant.buildType.name
95
96 if (name.equals(com.android.builder.BuilderConstants.DEBUG)) {
97 return; // Skip debug builds.
98 }
99 def suffix = name.capitalize()
100
101 def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
102 dependsOn variant.javaCompile
103 from variant.javaCompile.destinationDir
104 from 'LICENSE.txt'
105 }
106 def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
107 source android.sourceSets.main.allJava
108 classpath = files(variant.javaCompile.classpath.files) + files(
109 "${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
110 }
111
112 def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
113 classifier = 'javadoc'
114 from 'build/docs/javadoc'
115 }
116
117 def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
118 classifier = 'sources'
119 from android.sourceSets.main.allSource
120 }
121
122 project.ext.allSS.each { ss ->
123 javadocTask.source ss.allJava
124 sourcesJarTask.from ss.allSource
125 }
126
127 artifacts.add('archives', javadocJarTask);
128 artifacts.add('archives', sourcesJarTask);
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800129}
130
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800131uploadArchives {
132 repositories {
133 mavenDeployer {
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800134 repository(url: uri(rootProject.ext.supportRepoOut)) {
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800135 }
136
137 pom.project {
138 name 'Android Support Library v4'
139 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."
140 url 'http://developer.android.com/tools/extras/support-library.html'
141 inceptionYear '2011'
142
143 licenses {
144 license {
145 name 'The Apache Software License, Version 2.0'
146 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
147 distribution 'repo'
148 }
149 }
150
151 scm {
152 url "http://source.android.com"
153 connection "scm:git:https://android.googlesource.com/platform/frameworks/support"
154 }
155 developers {
156 developer {
157 name 'The Android Open Source Project'
158 }
159 }
160 }
161 }
162 }
163}