| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 1 | apply plugin: 'java' |
| 2 | |
| 3 | archivesBaseName = 'support-v4' |
| 4 | |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -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 | def eclairSS = createApiSourceset('eclair', 'eclair', '5', null) |
| 10 | def eclairMr1SS = createApiSourceset('eclairmr1', 'eclair-mr1', '7', eclairSS) |
| 11 | def froyoSS = createApiSourceset('froyo', 'froyo', '8', eclairMr1SS) |
| 12 | def gingerbreadSS = createApiSourceset('gingerbread', 'gingerbread', '9', froyoSS) |
| 13 | def honeycombSS = createApiSourceset('honeycomb', 'honeycomb', '11', gingerbreadSS) |
| 14 | def honeycombMr2SS = createApiSourceset('honeycombmr2', 'honeycomb_mr2', '13', honeycombSS) |
| 15 | def icsSS = createApiSourceset('ics', 'ics', '14', honeycombMr2SS) |
| 16 | def icsMr1SS = createApiSourceset('icsmr1', 'ics-mr1', '15', icsSS) |
| 17 | def jbSS = createApiSourceset('jellybean', 'jellybean', '16', icsMr1SS) |
| 18 | def jbMr1SS = createApiSourceset('jellybeanmr1', 'jellybean-mr1', '17', jbSS) |
| 19 | def jbMr2SS = createApiSourceset('jellybeanmr2', 'jellybean-mr2', '18', jbMr1SS) |
| 20 | def kitkatSS = createApiSourceset('kitkat', 'kitkat', '19', jbMr2SS) |
| Xavier Ducrohet | 261f67b | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 21 | def api20SS = createApiSourceset('api20', 'api20', 'current', kitkatSS) |
| Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 22 | |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 23 | // setup the main code to depend on the above through the highest platform-specific sourceset. |
| Xavier Ducrohet | 261f67b | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 24 | setupDependencies('compile', api20SS) |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 25 | // -------------------------- |
| 26 | |
| 27 | def createApiSourceset(String name, String folder, String apiLevel, SourceSet previousSource) { |
| 28 | def sourceSet = sourceSets.create(name) |
| 29 | sourceSet.java.srcDirs = [folder] |
| 30 | |
| 31 | def configName = sourceSet.getCompileConfigurationName() |
| 32 | |
| 33 | project.getDependencies().add(configName, getAndroidPrebuilt(apiLevel)) |
| 34 | if (previousSource != null) { |
| 35 | setupDependencies(configName, previousSource) |
| 36 | } |
| 37 | |
| 38 | project.jar { |
| 39 | from sourceSet.output |
| 40 | } |
| 41 | |
| 42 | return sourceSet |
| 43 | } |
| 44 | |
| 45 | def setupDependencies(String configName, SourceSet previousSourceSet) { |
| 46 | project.getDependencies().add(configName, previousSourceSet.output) |
| 47 | project.getDependencies().add(configName, previousSourceSet.compileClasspath) |
| 48 | } |
| 49 | |
| 50 | // the main sourceset and its dependencies |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 51 | sourceSets { |
| Xavier Ducrohet | 15474b9 | 2014-03-21 17:11:38 -0700 | [diff] [blame] | 52 | main.java.srcDirs = ['java'] |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | dependencies { |
| Tor Norbye | 05568b7 | 2014-03-20 19:19:52 -0700 | [diff] [blame] | 56 | compile project(':support-annotations') |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 57 | compile getAndroidPrebuilt('4') |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 60 | uploadArchives { |
| 61 | repositories { |
| 62 | mavenDeployer { |
| Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 63 | repository(url: uri(rootProject.ext.supportRepoOut)) { |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | pom.project { |
| 67 | name 'Android Support Library v4' |
| 68 | 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." |
| 69 | url 'http://developer.android.com/tools/extras/support-library.html' |
| 70 | inceptionYear '2011' |
| 71 | |
| 72 | licenses { |
| 73 | license { |
| 74 | name 'The Apache Software License, Version 2.0' |
| 75 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 76 | distribution 'repo' |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | scm { |
| 81 | url "http://source.android.com" |
| 82 | connection "scm:git:https://android.googlesource.com/platform/frameworks/support" |
| 83 | } |
| 84 | developers { |
| 85 | developer { |
| 86 | name 'The Android Open Source Project' |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // configuration for the javadoc to include all source sets. |
| 95 | javadoc { |
| 96 | source sourceSets.main.allJava |
| 97 | source sourceSets.eclair.allJava |
| Raphael Moll | 5057daa | 2013-10-29 17:01:14 -0700 | [diff] [blame] | 98 | source sourceSets.eclairmr1.allJava |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 99 | source sourceSets.froyo.allJava |
| 100 | source sourceSets.gingerbread.allJava |
| 101 | source sourceSets.honeycomb.allJava |
| 102 | source sourceSets.honeycombmr2.allJava |
| 103 | source sourceSets.ics.allJava |
| 104 | source sourceSets.icsmr1.allJava |
| 105 | source sourceSets.jellybean.allJava |
| 106 | source sourceSets.jellybeanmr1.allJava |
| Alan Viverette | 5df122f | 2013-09-23 10:44:38 -0700 | [diff] [blame] | 107 | source sourceSets.jellybeanmr2.allJava |
| 108 | source sourceSets.kitkat.allJava |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | // custom tasks for creating source/javadoc jars |
| 112 | task sourcesJar(type: Jar, dependsOn:classes) { |
| 113 | classifier = 'sources' |
| 114 | from sourceSets.main.allSource |
| 115 | from sourceSets.eclair.allSource |
| Raphael Moll | 5057daa | 2013-10-29 17:01:14 -0700 | [diff] [blame] | 116 | from sourceSets.eclairmr1.allSource |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 117 | from sourceSets.froyo.allSource |
| 118 | from sourceSets.gingerbread.allSource |
| 119 | from sourceSets.honeycomb.allSource |
| 120 | from sourceSets.honeycombmr2.allSource |
| 121 | from sourceSets.ics.allSource |
| 122 | from sourceSets.icsmr1.allSource |
| 123 | from sourceSets.jellybean.allSource |
| 124 | from sourceSets.jellybeanmr1.allSource |
| Alan Viverette | 5df122f | 2013-09-23 10:44:38 -0700 | [diff] [blame] | 125 | from sourceSets.jellybeanmr2.allSource |
| 126 | from sourceSets.kitkat.allSource |
| Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | task javadocJar(type: Jar, dependsOn:javadoc) { |
| 130 | classifier 'javadoc' |
| 131 | from javadoc.destinationDir |
| 132 | } |
| 133 | |
| 134 | // add javadoc/source jar tasks as artifacts |
| 135 | artifacts { |
| 136 | archives jar |
| 137 | archives sourcesJar |
| 138 | archives javadocJar |
| 139 | } |