blob: 5060842b2d06cbb7c733bd1be921c8595dad24dc [file] [log] [blame]
Yigit Boyar02a9e8c2016-01-26 20:41:00 -08001apply plugin: 'com.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
Yigit Boyar5932b6f2014-04-30 13:43:59 -070054android {
55 compileSdkVersion 13
Yigit Boyar5932b6f2014-04-30 13:43:59 -070056
57 defaultConfig {
58 minSdkVersion 13
59 // TODO: get target from branch
60 //targetSdkVersion 19
61 }
62
63
64 sourceSets {
65 main.manifest.srcFile 'AndroidManifest.xml'
66 main.java.srcDirs = ['java']
67 main.aidl.srcDirs = ['java']
68
69 androidTest.setRoot('tests')
70 androidTest.java.srcDir 'tests/java'
71 }
72
73 lintOptions {
74 // TODO: fix errors and reenable.
75 abortOnError false
76 }
Yigit Boyar02a9e8c2016-01-26 20:41:00 -080077
78 compileOptions {
79 sourceCompatibility JavaVersion.VERSION_1_7
80 targetCompatibility JavaVersion.VERSION_1_7
81 }
Yigit Boyar5932b6f2014-04-30 13:43:59 -070082}
83
84android.libraryVariants.all { variant ->
85 variant.javaCompile.dependsOn internalJar
86
87 def name = variant.buildType.name
88
Chris Banes4efd0382015-03-05 20:04:05 +000089 if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
Yigit Boyar5932b6f2014-04-30 13:43:59 -070090 return; // Skip debug builds.
91 }
92 def suffix = name.capitalize()
93
94 def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
95 dependsOn variant.javaCompile
96 from variant.javaCompile.destinationDir
97 from 'LICENSE.txt'
98 }
99 def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
Chris Banes4efd0382015-03-05 20:04:05 +0000100 source android.sourceSets.main.java
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700101 classpath = files(variant.javaCompile.classpath.files) + files(
Chris Banes4efd0382015-03-05 20:04:05 +0000102 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700103 }
104
105 def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
106 classifier = 'javadoc'
107 from 'build/docs/javadoc'
108 }
109
110 def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
111 classifier = 'sources'
Chris Banes4efd0382015-03-05 20:04:05 +0000112 from android.sourceSets.main.java.srcDirs
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700113 }
114
115 project.ext.allSS.each { ss ->
Chris Banes4efd0382015-03-05 20:04:05 +0000116 javadocTask.source ss.java
117 sourcesJarTask.from ss.java.srcDirs
Yigit Boyar5932b6f2014-04-30 13:43:59 -0700118 }
119
120 artifacts.add('archives', javadocJarTask);
121 artifacts.add('archives', sourcesJarTask);
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800122}
123
124uploadArchives {
125 repositories {
126 mavenDeployer {
127
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800128 repository(url: uri(rootProject.ext.supportRepoOut)) {
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800129 }
130
131 pom.project {
132 name 'Android Support Library v13'
133 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."
134 url 'http://developer.android.com/tools/extras/support-library.html'
135 inceptionYear '2011'
136
137 licenses {
138 license {
139 name 'The Apache Software License, Version 2.0'
140 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
141 distribution 'repo'
142 }
143 }
144
145 scm {
146 url "http://source.android.com"
147 connection "scm:git:https://android.googlesource.com/platform/frameworks/support"
148 }
149 developers {
150 developer {
151 name 'The Android Open Source Project'
152 }
153 }
154 }
155 }
156 }
157}