blob: d7eddbb681e6a099b5276a918f6df280296374dc [file] [log] [blame]
Yigit Boyar5932b6f2014-04-30 13:43:59 -07001apply plugin: 'android-library'
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -08002
3archivesBaseName = 'support-v13'
4
Yigit Boyar5932b6f2014-04-30 13:43:59 -07005// --------------------------
6// TO ADD NEW PLATFORM SPECIFIC CODE, UPDATE THIS:
7// create and configure the sourcesets/dependencies for platform-specific code.
8// values are: sourceset name, source folder name, api level, previous sourceset.
9
10ext.allSS = []
11
Chris Banes1981f8c2015-06-10 10:06:24 +010012def icsSS = createApiSourceset('ics', 'ics', '14', null)
13def icsMr1SS = createApiSourceset('icsmr1', 'ics-mr1', '15', icsSS)
14def api23SS = createApiSourceset('api23', 'api23', 'current', icsMr1SS)
Yigit Boyar5932b6f2014-04-30 13:43:59 -070015
16def createApiSourceset(String name, String folder, String apiLevel, SourceSet previousSource) {
17 def sourceSet = sourceSets.create(name)
18 sourceSet.java.srcDirs = [folder]
19
20 def configName = sourceSet.getCompileConfigurationName()
21
22 project.getDependencies().add(configName, getAndroidPrebuilt(apiLevel))
23 if (previousSource != null) {
24 setupDependencies(configName, previousSource)
25 }
26 ext.allSS.add(sourceSet)
27 return sourceSet
28}
29
30def setupDependencies(String configName, SourceSet previousSourceSet) {
31 project.getDependencies().add(configName, previousSourceSet.output)
32 project.getDependencies().add(configName, previousSourceSet.compileClasspath)
33}
34
35// create a jar task for the code above
36tasks.create(name: "internalJar", type: Jar) {
37 baseName "internal_impl"
38}
39
40ext.allSS.each { ss ->
41 internalJar.from ss.output
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080042}
43
44dependencies {
Xavier Ducrohet855a9222014-01-02 19:00:43 -080045 compile project(':support-v4')
Yigit Boyar5932b6f2014-04-30 13:43:59 -070046
47 // add the internal implementation as a dependency.
48 // this is not enough to make the regular compileJava task
49 // depend on the generation of this jar. This is done below
50 // when manipulating the libraryVariants.
51 compile files(internalJar.archivePath)
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080052}
53
Justin Klaassen68e7adb2016-01-21 12:50:47 -080054sourceCompatibility = JavaVersion.VERSION_1_7
55targetCompatibility = JavaVersion.VERSION_1_7
56
Yigit Boyar5932b6f2014-04-30 13:43:59 -070057android {
58 compileSdkVersion 13
Yigit Boyar5932b6f2014-04-30 13:43:59 -070059
60 defaultConfig {
61 minSdkVersion 13
62 // TODO: get target from branch
63 //targetSdkVersion 19
64 }
65
Yigit Boyar5932b6f2014-04-30 13:43:59 -070066 sourceSets {
67 main.manifest.srcFile 'AndroidManifest.xml'
68 main.java.srcDirs = ['java']
69 main.aidl.srcDirs = ['java']
70
71 androidTest.setRoot('tests')
72 androidTest.java.srcDir 'tests/java'
73 }
74
Justin Klaassen68e7adb2016-01-21 12:50:47 -080075 compileOptions {
76 sourceCompatibility JavaVersion.VERSION_1_7
77 targetCompatibility JavaVersion.VERSION_1_7
78 }
79
Yigit Boyar5932b6f2014-04-30 13:43:59 -070080 lintOptions {
81 // TODO: fix errors and reenable.
82 abortOnError false
83 }
84}
85
86android.libraryVariants.all { variant ->
87 variant.javaCompile.dependsOn internalJar
88
89 def name = variant.buildType.name
90
Chris Banes4efd0382015-03-05 20:04:05 +000091 if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
Yigit Boyar5932b6f2014-04-30 13:43:59 -070092 return; // Skip debug builds.
93 }
94 def suffix = name.capitalize()
95
96 def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
97 dependsOn variant.javaCompile
98 from variant.javaCompile.destinationDir
99 from 'LICENSE.txt'
100 }
101 def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
Chris Banes4efd0382015-03-05 20:04:05 +0000102 source android.sourceSets.main.java
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700103 classpath = files(variant.javaCompile.classpath.files) + files(
Chris Banes4efd0382015-03-05 20:04:05 +0000104 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700105 }
106
107 def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
108 classifier = 'javadoc'
109 from 'build/docs/javadoc'
110 }
111
112 def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
113 classifier = 'sources'
Chris Banes4efd0382015-03-05 20:04:05 +0000114 from android.sourceSets.main.java.srcDirs
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700115 }
116
117 project.ext.allSS.each { ss ->
Chris Banes4efd0382015-03-05 20:04:05 +0000118 javadocTask.source ss.java
119 sourcesJarTask.from ss.java.srcDirs
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700120 }
121
122 artifacts.add('archives', javadocJarTask);
123 artifacts.add('archives', sourcesJarTask);
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800124}
125
126uploadArchives {
127 repositories {
128 mavenDeployer {
129
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800130 repository(url: uri(rootProject.ext.supportRepoOut)) {
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800131 }
132
133 pom.project {
134 name 'Android Support Library v13'
135 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 13 or later."
136 url 'http://developer.android.com/tools/extras/support-library.html'
137 inceptionYear '2011'
138
139 licenses {
140 license {
141 name 'The Apache Software License, Version 2.0'
142 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
143 distribution 'repo'
144 }
145 }
146
147 scm {
148 url "http://source.android.com"
149 connection "scm:git:https://android.googlesource.com/platform/frameworks/support"
150 }
151 developers {
152 developer {
153 name 'The Android Open Source Project'
154 }
155 }
156 }
157 }
158 }
159}