普通文本  |  114行  |  3.84 KB

apply plugin: 'com.android.library'

archivesBaseName = 'mediarouter-v7'


// some of the source requires compiling against a newer API.
// Right now, use normal Java source sets to compile those into a jar and 
// package it as a local dependencies inside the library aar.

createApiSourceSets(project, gradle.ext.studioCompat.modules.mediaRouter.apiTargets)
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
setApiModuleDependencies(project, dependencies, gradle.ext.studioCompat.modules.mediaRouter.dependencies)

android {
    compileSdkVersion project.ext.currentSdk

    sourceSets {
        main.manifest.srcFile 'AndroidManifest.xml'
        main.java.srcDir 'src'
        main.res.srcDir 'res'
        main.assets.srcDir 'assets'
        main.resources.srcDir 'src'

        // this moves src/instrumentTest to tests so all folders follow:
        // tests/java, tests/res, tests/assets, ...
        // This is a *reset* so it replaces the default paths
        androidTest.setRoot('tests')
        androidTest.java.srcDir 'tests/src'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    lintOptions {
        // TODO: fix errors and reenable.
        abortOnError false
    }
}

android.libraryVariants.all { variant ->
    def name = variant.buildType.name

    if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
        return; // Skip debug builds.
    }
    def suffix = name.capitalize()

    def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
        dependsOn variant.javaCompile
        from variant.javaCompile.destinationDir
        from 'LICENSE.txt'
    }
    def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
        source android.sourceSets.main.java
        classpath = files(variant.javaCompile.classpath.files) + files(
                "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
    }

    def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
        classifier = 'javadoc'
        from 'build/docs/javadoc'
    }

    def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.srcDirs
    }

    project.ext.allSS.each { ss ->
        javadocTask.source ss.java
        sourcesJarTask.from ss.java.srcDirs
    }

    artifacts.add('archives', javadocJarTask);
    artifacts.add('archives', sourcesJarTask);
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: uri(rootProject.ext.supportRepoOut)) {
            }

            pom.project {
                name 'Android MediaRouter Support Library'
                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."
                url 'http://developer.android.com/tools/extras/support-library.html'
                inceptionYear '2011'

                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution 'repo'
                    }
                }

                scm {
                    url "http://source.android.com"
                    connection "scm:git:https://android.googlesource.com/platform/frameworks/support"
                }
                developers {
                    developer {
                        name 'The Android Open Source Project'
                    }
                }
            }
        }
    }
}