build.gradle revision c725edb8d5fdff0128c2dbb80fa073b3763d166c
1apply plugin: 'com.android.library' 2archivesBaseName = 'support-v4' 3 4// create a jar task for the code internal implementation 5tasks.create(name: "internalJar", type: Jar) { 6 baseName "internal_impl" 7} 8 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. 13 14ext.allSS = [] 15 16def baseSS = createApiSourceset('donut', 'donut', '4', null) 17def eclairSS = createApiSourceset('eclair', 'eclair', '5', baseSS) 18def eclairMr1SS = createApiSourceset('eclairmr1', 'eclair-mr1', '7', eclairSS) 19def froyoSS = createApiSourceset('froyo', 'froyo', '8', eclairMr1SS) 20def gingerbreadSS = createApiSourceset('gingerbread', 'gingerbread', '9', froyoSS) 21def honeycombSS = createApiSourceset('honeycomb', 'honeycomb', '11', gingerbreadSS) 22def honeycombMr1SS = createApiSourceset('honeycombmr1', 'honeycomb_mr1', '12', honeycombSS) 23def honeycombMr2SS = createApiSourceset('honeycombmr2', 'honeycomb_mr2', '13', honeycombMr1SS) 24def icsSS = createApiSourceset('ics', 'ics', '14', honeycombMr2SS) 25def icsMr1SS = createApiSourceset('icsmr1', 'ics-mr1', '15', icsSS) 26def jbSS = createApiSourceset('jellybean', 'jellybean', '16', icsMr1SS) 27def jbMr1SS = createApiSourceset('jellybeanmr1', 'jellybean-mr1', '17', jbSS) 28def jbMr2SS = createApiSourceset('jellybeanmr2', 'jellybean-mr2', '18', jbMr1SS) 29def kitkatSS = createApiSourceset('kitkat', 'kitkat', '19', jbMr2SS) 30def api20SS = createApiSourceset('api20', 'api20', '20', kitkatSS) 31def api21SS = createApiSourceset('api21', 'api21', '21', api20SS) 32def api22SS = createApiSourceset('api22', 'api22', '22', api21SS) 33def api23SS = createApiSourceset('api23', 'api23', 'current', api22SS) 34def api24SS = createApiSourceset('api24', 'api24', 'current', api23SS) 35 36 37def createApiSourceset(String name, String folder, String apiLevel, SourceSet previousSource) { 38 def sourceSet = sourceSets.create(name) 39 sourceSet.java.srcDirs = [folder] 40 41 def configName = sourceSet.getCompileConfigurationName() 42 43 project.getDependencies().add(configName, getAndroidPrebuilt(apiLevel)) 44 if (previousSource != null) { 45 setupDependencies(configName, previousSource) 46 } 47 ext.allSS.add(sourceSet) 48 49 internalJar.from sourceSet.output 50 51 return sourceSet 52} 53 54def setupDependencies(String configName, SourceSet previousSourceSet) { 55 project.getDependencies().add(configName, previousSourceSet.output) 56 project.getDependencies().add(configName, previousSourceSet.compileClasspath) 57} 58 59dependencies { 60 compile project(':support-annotations') 61 donutCompile project(':support-annotations') 62 63 // add the internal implementation as a dependency. 64 // this is not enough to make the regular compileJava task 65 // depend on the generation of this jar. This is done below 66 // when manipulating the libraryVariants. 67 compile files(internalJar.archivePath) 68 69 androidTestCompile ('com.android.support.test:runner:0.4.1') { 70 exclude module: 'support-annotations' 71 } 72 androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.1') { 73 exclude module: 'support-annotations' 74 } 75 testCompile 'junit:junit:4.12' 76} 77 78android { 79 compileSdkVersion 4 80 81 defaultConfig { 82 minSdkVersion 4 83 // TODO: get target from branch 84 //targetSdkVersion 19 85 86 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 87 } 88 89 sourceSets { 90 main.manifest.srcFile 'AndroidManifest.xml' 91 main.java.srcDirs = ['java'] 92 main.aidl.srcDirs = ['java'] 93 94 androidTest.setRoot('tests') 95 androidTest.java.srcDir 'tests/java' 96 androidTest.res.srcDir 'tests/res' 97 androidTest.manifest.srcFile 'tests/AndroidManifest.xml' 98 } 99 100 lintOptions { 101 // TODO: fix errors and reenable. 102 abortOnError false 103 } 104 105 compileOptions { 106 sourceCompatibility JavaVersion.VERSION_1_7 107 targetCompatibility JavaVersion.VERSION_1_7 108 } 109 110 testOptions { 111 unitTests.returnDefaultValues = true 112 compileSdkVersion project.ext.currentSdk 113 } 114} 115 116android.libraryVariants.all { variant -> 117 variant.javaCompile.dependsOn internalJar 118 119 def name = variant.buildType.name 120 121 if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) { 122 return; // Skip debug builds. 123 } 124 def suffix = name.capitalize() 125 126 def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){ 127 dependsOn variant.javaCompile 128 from variant.javaCompile.destinationDir 129 from 'LICENSE.txt' 130 } 131 def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) { 132 source android.sourceSets.main.java 133 classpath = files(variant.javaCompile.classpath.files) + files( 134 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar") 135 } 136 137 def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) { 138 classifier = 'javadoc' 139 from 'build/docs/javadoc' 140 } 141 142 def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) { 143 classifier = 'sources' 144 from android.sourceSets.main.java.srcDirs 145 exclude('android/content/pm/**') 146 exclude('android/service/media/**') 147 } 148 149 project.ext.allSS.each { ss -> 150 javadocTask.source ss.java 151 sourcesJarTask.from ss.java.srcDirs 152 } 153 154 artifacts.add('archives', javadocJarTask); 155 artifacts.add('archives', sourcesJarTask); 156} 157 158uploadArchives { 159 repositories { 160 mavenDeployer { 161 repository(url: uri(rootProject.ext.supportRepoOut)) { 162 } 163 164 pom.project { 165 name 'Android Support Library v4' 166 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." 167 url 'http://developer.android.com/tools/extras/support-library.html' 168 inceptionYear '2011' 169 170 licenses { 171 license { 172 name 'The Apache Software License, Version 2.0' 173 url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 174 distribution 'repo' 175 } 176 } 177 178 scm { 179 url "http://source.android.com" 180 connection "scm:git:https://android.googlesource.com/platform/frameworks/support" 181 } 182 developers { 183 developer { 184 name 'The Android Open Source Project' 185 } 186 } 187 } 188 } 189 } 190} 191