| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 1 | apply plugin: 'android-library' |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 2 | archivesBaseName = 'support-v4' |
| 3 | |
| Xavier Ducrohet | 9acddc7 | 2014-05-28 22:20:01 -0700 | [diff] [blame] | 4 | // create a jar task for the code internal implementation |
| 5 | tasks.create(name: "internalJar", type: Jar) { |
| 6 | baseName "internal_impl" |
| 7 | } |
| 8 | |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 9 | // -------------------------- |
| 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 Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 13 | |
| 14 | ext.allSS = [] |
| 15 | |
| 16 | def baseSS = createApiSourceset('donut', 'donut', '4', null) |
| 17 | def eclairSS = createApiSourceset('eclair', 'eclair', '5', baseSS) |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 18 | def eclairMr1SS = createApiSourceset('eclairmr1', 'eclair-mr1', '7', eclairSS) |
| 19 | def froyoSS = createApiSourceset('froyo', 'froyo', '8', eclairMr1SS) |
| 20 | def gingerbreadSS = createApiSourceset('gingerbread', 'gingerbread', '9', froyoSS) |
| 21 | def honeycombSS = createApiSourceset('honeycomb', 'honeycomb', '11', gingerbreadSS) |
| Chris Banes | c55f505 | 2014-07-03 15:40:30 +0100 | [diff] [blame] | 22 | def honeycombMr1SS = createApiSourceset('honeycombmr1', 'honeycomb_mr1', '12', honeycombSS) |
| 23 | def honeycombMr2SS = createApiSourceset('honeycombmr2', 'honeycomb_mr2', '13', honeycombMr1SS) |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 24 | def icsSS = createApiSourceset('ics', 'ics', '14', honeycombMr2SS) |
| 25 | def icsMr1SS = createApiSourceset('icsmr1', 'ics-mr1', '15', icsSS) |
| 26 | def jbSS = createApiSourceset('jellybean', 'jellybean', '16', icsMr1SS) |
| 27 | def jbMr1SS = createApiSourceset('jellybeanmr1', 'jellybean-mr1', '17', jbSS) |
| 28 | def jbMr2SS = createApiSourceset('jellybeanmr2', 'jellybean-mr2', '18', jbMr1SS) |
| 29 | def kitkatSS = createApiSourceset('kitkat', 'kitkat', '19', jbMr2SS) |
| Chris Banes | 1981f8c | 2015-06-10 10:06:24 +0100 | [diff] [blame] | 30 | def api20SS = createApiSourceset('api20', 'api20', '20', kitkatSS) |
| 31 | def api21SS = createApiSourceset('api21', 'api21', '21', api20SS) |
| 32 | def api22SS = createApiSourceset('api22', 'api22', '22', api21SS) |
| Chris Banes | 44918a9 | 2015-01-08 11:55:55 +0000 | [diff] [blame] | 33 | def api23SS = createApiSourceset('api23', 'api23', 'current', api22SS) |
| Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 34 | |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 35 | |
| 36 | def 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 Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 46 | ext.allSS.add(sourceSet) |
| Xavier Ducrohet | 9acddc7 | 2014-05-28 22:20:01 -0700 | [diff] [blame] | 47 | |
| 48 | internalJar.from sourceSet.output |
| 49 | |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 50 | return sourceSet |
| 51 | } |
| 52 | |
| 53 | def setupDependencies(String configName, SourceSet previousSourceSet) { |
| 54 | project.getDependencies().add(configName, previousSourceSet.output) |
| 55 | project.getDependencies().add(configName, previousSourceSet.compileClasspath) |
| 56 | } |
| 57 | |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 58 | dependencies { |
| Tor Norbye | 05568b7 | 2014-03-20 19:19:52 -0700 | [diff] [blame] | 59 | compile project(':support-annotations') |
| Yigit Boyar | d392c8c | 2014-10-09 11:30:18 -0700 | [diff] [blame] | 60 | donutCompile project(':support-annotations') |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 61 | |
| 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 | |
| 69 | android { |
| 70 | compileSdkVersion 4 |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 71 | |
| 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 Banes | af26d9f | 2015-01-20 19:13:52 +0000 | [diff] [blame] | 91 | |
| 92 | compileOptions { |
| 93 | sourceCompatibility JavaVersion.VERSION_1_7 |
| 94 | targetCompatibility JavaVersion.VERSION_1_7 |
| 95 | } |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | android.libraryVariants.all { variant -> |
| 99 | variant.javaCompile.dependsOn internalJar |
| 100 | |
| 101 | def name = variant.buildType.name |
| 102 | |
| Chris Banes | 4efd038 | 2015-03-05 20:04:05 +0000 | [diff] [blame] | 103 | if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) { |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 104 | 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 Banes | 4efd038 | 2015-03-05 20:04:05 +0000 | [diff] [blame] | 114 | source android.sourceSets.main.java |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 115 | classpath = files(variant.javaCompile.classpath.files) + files( |
| Chris Banes | 4efd038 | 2015-03-05 20:04:05 +0000 | [diff] [blame] | 116 | "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar") |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 117 | } |
| 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 Banes | 4efd038 | 2015-03-05 20:04:05 +0000 | [diff] [blame] | 126 | from android.sourceSets.main.java.srcDirs |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | project.ext.allSS.each { ss -> |
| Chris Banes | 4efd038 | 2015-03-05 20:04:05 +0000 | [diff] [blame] | 130 | javadocTask.source ss.java |
| 131 | sourcesJarTask.from ss.java.srcDirs |
| Griff Hazen | 43227bb | 2014-05-28 07:59:33 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | artifacts.add('archives', javadocJarTask); |
| 135 | artifacts.add('archives', sourcesJarTask); |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 136 | } |
| 137 | |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 138 | uploadArchives { |
| 139 | repositories { |
| 140 | mavenDeployer { |
| Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 141 | repository(url: uri(rootProject.ext.supportRepoOut)) { |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 142 | } |
| 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 | } |