Home | History | Annotate | Download | only in v4
      1 apply plugin: 'android-library'
      2 archivesBaseName = 'support-v4'
      3 
      4 // create a jar task for the code internal implementation
      5 tasks.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 
     14 ext.allSS = []
     15 
     16 def baseSS         = createApiSourceset('donut',         'donut',          '4',       null)
     17 def eclairSS       = createApiSourceset('eclair',       'eclair',        '5',       baseSS)
     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 honeycombMr1SS = createApiSourceset('honeycombmr1', 'honeycomb_mr1', '12',      honeycombSS)
     23 def honeycombMr2SS = createApiSourceset('honeycombmr2', 'honeycomb_mr2', '13',      honeycombMr1SS)
     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)
     30 def api20SS        = createApiSourceset('api20',        'api20',         '20',      kitkatSS)
     31 def api21SS        = createApiSourceset('api21',        'api21',         '21',      api20SS)
     32 def api22SS        = createApiSourceset('api22',        'api22',         '22',      api21SS)
     33 def api23SS        = createApiSourceset('api23',        'api23',         'current', api22SS)
     34 
     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     }
     46     ext.allSS.add(sourceSet)
     47 
     48     internalJar.from sourceSet.output
     49 
     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 
     58 dependencies {
     59     compile project(':support-annotations')
     60     donutCompile project(':support-annotations')
     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
     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     }
     91 
     92     compileOptions {
     93         sourceCompatibility JavaVersion.VERSION_1_7
     94         targetCompatibility JavaVersion.VERSION_1_7
     95     }
     96 }
     97 
     98 android.libraryVariants.all { variant ->
     99     variant.javaCompile.dependsOn internalJar
    100 
    101     def name = variant.buildType.name
    102 
    103     if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
    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) {
    114         source android.sourceSets.main.java
    115         classpath = files(variant.javaCompile.classpath.files) + files(
    116                 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
    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'
    126         from android.sourceSets.main.java.srcDirs
    127     }
    128 
    129     project.ext.allSS.each { ss ->
    130         javadocTask.source ss.java
    131         sourcesJarTask.from ss.java.srcDirs
    132     }
    133 
    134     artifacts.add('archives', javadocJarTask);
    135     artifacts.add('archives', sourcesJarTask);
    136 }
    137 
    138 uploadArchives {
    139     repositories {
    140         mavenDeployer {
    141             repository(url: uri(rootProject.ext.supportRepoOut)) {
    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 }
    171