Yigit Boyar | 5932b6f | 2014-04-30 13:43:59 -0700 | [diff] [blame^] | 1 | apply plugin: 'android-library' |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 2 | |
| 3 | archivesBaseName = 'support-v13' |
| 4 | |
Yigit Boyar | 5932b6f | 2014-04-30 13:43:59 -0700 | [diff] [blame^] | 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 | |
| 15 | def createApiSourceset(String name, String folder, String apiLevel, SourceSet previousSource) { |
| 16 | def sourceSet = sourceSets.create(name) |
| 17 | sourceSet.java.srcDirs = [folder] |
| 18 | |
| 19 | def configName = sourceSet.getCompileConfigurationName() |
| 20 | |
| 21 | project.getDependencies().add(configName, getAndroidPrebuilt(apiLevel)) |
| 22 | if (previousSource != null) { |
| 23 | setupDependencies(configName, previousSource) |
| 24 | } |
| 25 | ext.allSS.add(sourceSet) |
| 26 | return sourceSet |
| 27 | } |
| 28 | |
| 29 | def setupDependencies(String configName, SourceSet previousSourceSet) { |
| 30 | project.getDependencies().add(configName, previousSourceSet.output) |
| 31 | project.getDependencies().add(configName, previousSourceSet.compileClasspath) |
| 32 | } |
| 33 | |
| 34 | // create a jar task for the code above |
| 35 | tasks.create(name: "internalJar", type: Jar) { |
| 36 | baseName "internal_impl" |
| 37 | } |
| 38 | |
| 39 | ext.allSS.each { ss -> |
| 40 | internalJar.from ss.output |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | dependencies { |
Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 44 | compile project(':support-v4') |
Yigit Boyar | 5932b6f | 2014-04-30 13:43:59 -0700 | [diff] [blame^] | 45 | |
| 46 | // add the internal implementation as a dependency. |
| 47 | // this is not enough to make the regular compileJava task |
| 48 | // depend on the generation of this jar. This is done below |
| 49 | // when manipulating the libraryVariants. |
| 50 | compile files(internalJar.archivePath) |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Yigit Boyar | 5932b6f | 2014-04-30 13:43:59 -0700 | [diff] [blame^] | 53 | android { |
| 54 | compileSdkVersion 13 |
| 55 | buildToolsVersion "19.0.1" |
| 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.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.allJava |
| 96 | classpath = files(variant.javaCompile.classpath.files) + files( |
| 97 | "${android.plugin.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.allSource |
| 108 | } |
| 109 | |
| 110 | project.ext.allSS.each { ss -> |
| 111 | javadocTask.source ss.allJava |
| 112 | sourcesJarTask.from ss.allSource |
| 113 | } |
| 114 | |
| 115 | artifacts.add('archives', javadocJarTask); |
| 116 | artifacts.add('archives', sourcesJarTask); |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | uploadArchives { |
| 120 | repositories { |
| 121 | mavenDeployer { |
| 122 | |
Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 123 | repository(url: uri(rootProject.ext.supportRepoOut)) { |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 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 | } |