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