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