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