blob: a056973e6d598b8bd8b548962d4d2cf6194a457c [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)
Chris Banesc55f5052014-07-03 15:40:30 +010022def honeycombMr1SS = createApiSourceset('honeycombmr1', 'honeycomb_mr1', '12', honeycombSS)
23def honeycombMr2SS = createApiSourceset('honeycombmr2', 'honeycomb_mr2', '13', honeycombMr1SS)
Xavier Ducrohet15474b92014-03-21 17:11:38 -070024def icsSS = createApiSourceset('ics', 'ics', '14', honeycombMr2SS)
25def icsMr1SS = createApiSourceset('icsmr1', 'ics-mr1', '15', icsSS)
26def jbSS = createApiSourceset('jellybean', 'jellybean', '16', icsMr1SS)
27def jbMr1SS = createApiSourceset('jellybeanmr1', 'jellybean-mr1', '17', jbSS)
28def jbMr2SS = createApiSourceset('jellybeanmr2', 'jellybean-mr2', '18', jbMr1SS)
29def kitkatSS = createApiSourceset('kitkat', 'kitkat', '19', jbMr2SS)
Chris Banes1981f8c2015-06-10 10:06:24 +010030def api20SS = createApiSourceset('api20', 'api20', '20', kitkatSS)
31def api21SS = createApiSourceset('api21', 'api21', '21', api20SS)
32def api22SS = createApiSourceset('api22', 'api22', '22', api21SS)
Chris Banes44918a92015-01-08 11:55:55 +000033def api23SS = createApiSourceset('api23', 'api23', 'current', api22SS)
Xavier Ducrohet855a9222014-01-02 19:00:43 -080034
Xavier Ducrohet15474b92014-03-21 17:11:38 -070035
36def createApiSourceset(String name, String folder, String apiLevel, SourceSet previousSource) {
37 def sourceSet = sourceSets.create(name)
38 sourceSet.java.srcDirs = [folder]
39
40 def configName = sourceSet.getCompileConfigurationName()
41
42 project.getDependencies().add(configName, getAndroidPrebuilt(apiLevel))
43 if (previousSource != null) {
44 setupDependencies(configName, previousSource)
45 }
Griff Hazen43227bb2014-05-28 07:59:33 -070046 ext.allSS.add(sourceSet)
Xavier Ducrohet9acddc72014-05-28 22:20:01 -070047
48 internalJar.from sourceSet.output
49
Xavier Ducrohet15474b92014-03-21 17:11:38 -070050 return sourceSet
51}
52
53def setupDependencies(String configName, SourceSet previousSourceSet) {
54 project.getDependencies().add(configName, previousSourceSet.output)
55 project.getDependencies().add(configName, previousSourceSet.compileClasspath)
56}
57
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080058dependencies {
Tor Norbye05568b72014-03-20 19:19:52 -070059 compile project(':support-annotations')
Yigit Boyard392c8c2014-10-09 11:30:18 -070060 donutCompile project(':support-annotations')
Griff Hazen43227bb2014-05-28 07:59:33 -070061
62 // add the internal implementation as a dependency.
63 // this is not enough to make the regular compileJava task
64 // depend on the generation of this jar. This is done below
65 // when manipulating the libraryVariants.
66 compile files(internalJar.archivePath)
67}
68
69android {
70 compileSdkVersion 4
Griff Hazen43227bb2014-05-28 07:59:33 -070071
72 defaultConfig {
73 minSdkVersion 4
74 // TODO: get target from branch
75 //targetSdkVersion 19
76 }
77
78 sourceSets {
79 main.manifest.srcFile 'AndroidManifest.xml'
80 main.java.srcDirs = ['java']
81 main.aidl.srcDirs = ['java']
82
83 androidTest.setRoot('tests')
84 androidTest.java.srcDir 'tests/java'
85 }
86
87 lintOptions {
88 // TODO: fix errors and reenable.
89 abortOnError false
90 }
Chris Banesaf26d9f2015-01-20 19:13:52 +000091
92 compileOptions {
93 sourceCompatibility JavaVersion.VERSION_1_7
94 targetCompatibility JavaVersion.VERSION_1_7
95 }
Griff Hazen43227bb2014-05-28 07:59:33 -070096}
97
98android.libraryVariants.all { variant ->
99 variant.javaCompile.dependsOn internalJar
100
101 def name = variant.buildType.name
102
Chris Banes4efd0382015-03-05 20:04:05 +0000103 if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
Griff Hazen43227bb2014-05-28 07:59:33 -0700104 return; // Skip debug builds.
105 }
106 def suffix = name.capitalize()
107
108 def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
109 dependsOn variant.javaCompile
110 from variant.javaCompile.destinationDir
111 from 'LICENSE.txt'
112 }
113 def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
Chris Banes4efd0382015-03-05 20:04:05 +0000114 source android.sourceSets.main.java
Griff Hazen43227bb2014-05-28 07:59:33 -0700115 classpath = files(variant.javaCompile.classpath.files) + files(
Chris Banes4efd0382015-03-05 20:04:05 +0000116 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
Griff Hazen43227bb2014-05-28 07:59:33 -0700117 }
118
119 def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
120 classifier = 'javadoc'
121 from 'build/docs/javadoc'
122 }
123
124 def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
125 classifier = 'sources'
Chris Banes4efd0382015-03-05 20:04:05 +0000126 from android.sourceSets.main.java.srcDirs
Griff Hazen43227bb2014-05-28 07:59:33 -0700127 }
128
129 project.ext.allSS.each { ss ->
Chris Banes4efd0382015-03-05 20:04:05 +0000130 javadocTask.source ss.java
131 sourcesJarTask.from ss.java.srcDirs
Griff Hazen43227bb2014-05-28 07:59:33 -0700132 }
133
134 artifacts.add('archives', javadocJarTask);
135 artifacts.add('archives', sourcesJarTask);
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800136}
137
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800138uploadArchives {
139 repositories {
140 mavenDeployer {
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800141 repository(url: uri(rootProject.ext.supportRepoOut)) {
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800142 }
143
144 pom.project {
145 name 'Android Support Library v4'
146 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."
147 url 'http://developer.android.com/tools/extras/support-library.html'
148 inceptionYear '2011'
149
150 licenses {
151 license {
152 name 'The Apache Software License, Version 2.0'
153 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
154 distribution 'repo'
155 }
156 }
157
158 scm {
159 url "http://source.android.com"
160 connection "scm:git:https://android.googlesource.com/platform/frameworks/support"
161 }
162 developers {
163 developer {
164 name 'The Android Open Source Project'
165 }
166 }
167 }
168 }
169 }
170}