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