1apply plugin: 'com.android.library'
2
3archivesBaseName = 'mediarouter-v7'
4
5
6// some of the source requires compiling against a newer API.
7// Right now, use normal Java source sets to compile those into a jar and
8// package it as a local dependencies inside the library aar.
9
10createApiSourceSets(project, gradle.ext.studioCompat.modules.mediaRouter.apiTargets)
11sourceCompatibility = JavaVersion.VERSION_1_7
12targetCompatibility = JavaVersion.VERSION_1_7
13setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.mediaRouter.dependencies)
14
15android {
16    compileSdkVersion project.ext.currentSdk
17
18    sourceSets {
19        main.manifest.srcFile 'AndroidManifest.xml'
20        main.java.srcDir 'src'
21        main.res.srcDir 'res'
22        main.assets.srcDir 'assets'
23        main.resources.srcDir 'src'
24
25        // this moves src/instrumentTest to tests so all folders follow:
26        // tests/java, tests/res, tests/assets, ...
27        // This is a *reset* so it replaces the default paths
28        androidTest.setRoot('tests')
29        androidTest.java.srcDir 'tests/src'
30    }
31
32    compileOptions {
33        sourceCompatibility JavaVersion.VERSION_1_7
34        targetCompatibility JavaVersion.VERSION_1_7
35    }
36
37    lintOptions {
38        // TODO: fix errors and reenable.
39        abortOnError false
40    }
41}
42
43android.libraryVariants.all { variant ->
44    def name = variant.buildType.name
45
46    if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
47        return; // Skip debug builds.
48    }
49    def suffix = name.capitalize()
50
51    def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
52        dependsOn variant.javaCompile
53        from variant.javaCompile.destinationDir
54        from 'LICENSE.txt'
55    }
56    def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
57        source android.sourceSets.main.java
58        classpath = files(variant.javaCompile.classpath.files) + files(
59                "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
60    }
61
62    def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
63        classifier = 'javadoc'
64        from 'build/docs/javadoc'
65    }
66
67    def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
68        classifier = 'sources'
69        from android.sourceSets.main.java.srcDirs
70    }
71
72    project.ext.allSS.each { ss ->
73        javadocTask.source ss.java
74        sourcesJarTask.from ss.java.srcDirs
75    }
76
77    artifacts.add('archives', javadocJarTask);
78    artifacts.add('archives', sourcesJarTask);
79}
80
81uploadArchives {
82    repositories {
83        mavenDeployer {
84            repository(url: uri(rootProject.ext.supportRepoOut)) {
85            }
86
87            pom.project {
88                name 'Android MediaRouter Support Library'
89                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."
90                url 'http://developer.android.com/tools/extras/support-library.html'
91                inceptionYear '2011'
92
93                licenses {
94                    license {
95                        name 'The Apache Software License, Version 2.0'
96                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
97                        distribution 'repo'
98                    }
99                }
100
101                scm {
102                    url "http://source.android.com"
103                    connection "scm:git:https://android.googlesource.com/platform/frameworks/support"
104                }
105                developers {
106                    developer {
107                        name 'The Android Open Source Project'
108                    }
109                }
110            }
111        }
112    }
113}
114