| /* |
| * Copyright (C) 2014 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| apply plugin: 'android-library' |
| |
| sourceCompatibility = JavaVersion.VERSION_1_5 |
| targetCompatibility = JavaVersion.VERSION_1_5 |
| |
| repositories { |
| maven { url '../../../../prebuilts/tools/common/m2/repository' } |
| maven { url '../../../../prebuilts/tools/common/m2/internal' } |
| } |
| |
| android { |
| compileSdkVersion 19 |
| buildToolsVersion '19.0.3' |
| |
| // to overwrite debug variant |
| publishNonDefault true |
| |
| lintOptions { |
| abortOnError false |
| } |
| |
| packagingOptions { |
| exclude 'LICENSE.txt' |
| } |
| } |
| |
| // create separate scope for jarjar |
| configurations { |
| jarjar |
| } |
| |
| dependencies { |
| // set to provided since we're manually adding the JarJar'd version |
| provided files('../libs/dagger-1.2.1.jar') |
| provided files('../libs/dagger-compiler-1.2.1.jar') |
| provided files('../libs/guava-14.0.1.jar') |
| |
| compile project(':idling-resource-interface') |
| compile 'javax.annotation:javax.annotation-api:1.2' |
| compile 'javax.inject:javax.inject:1' |
| compile 'com.google.code.findbugs:jsr305:2.0.1' |
| compile 'org.hamcrest:hamcrest-library:1.1' |
| compile 'org.hamcrest:hamcrest-integration:1.1' |
| compile 'org.hamcrest:hamcrest-core:1.1' |
| compile 'com.squareup:javawriter:2.1.1' |
| |
| jarjar files('../libs/jarjar-1.4.jar') |
| |
| // Temporarily include the Google3 TestRunner as a static jar |
| // until it's merged with the Android one. |
| compile files('../libs/testrunner-runtime-1.1.jar') |
| compile files('../libs/testrunner-1.1.jar') |
| } |
| |
| android.libraryVariants.all { variant -> |
| |
| // To run unit tests against un-jarjar version of the lib. |
| if (variant.buildType.name.equals(com.android.builder.BuilderConstants.DEBUG)) { |
| println "Skipping debug build type." |
| return; |
| } |
| |
| def classesJar = "$project.buildDir/bundles/$variant.dirName/classes.jar" |
| def tmpClassesJarDir = "$project.buildDir/pre-jarjar/$variant.dirName" |
| def tmpClassesJar = "$tmpClassesJarDir/classes.jar" |
| |
| def depDaggerJar = "../libs/dagger-1.2.1.jar" |
| def depGuavaJar = "../libs/guava-14.0.1.jar" |
| def jarJarTaskName = "jarJar${variant.name.capitalize()}" |
| |
| task "$jarJarTaskName" << { |
| project.ant { |
| taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", |
| classpath: configurations.jarjar.asPath |
| jarjar(jarfile: "$classesJar", filesetmanifest: "merge") { |
| zipfileset(src: "$depGuavaJar") |
| zipfileset(src: "$depDaggerJar") |
| zipfileset(src: "$tmpClassesJar") |
| rule pattern: "com.google.common.**", |
| result: "com.google.android.apps.common.testing.deps.guava.@1" |
| rule pattern: "dagger.**", |
| result: "com.google.android.apps.common.testing.deps.dagger.@1" |
| } |
| } |
| } |
| |
| // get access to the normal jar class. Change its output to somewhere else, and make jarjar depend on it. |
| Jar classesJarTask = (Jar) project.tasks.getByName("package${variant.name.capitalize()}Jar") |
| |
| classesJarTask.destinationDir = project.file("$tmpClassesJarDir") |
| project.tasks.getByName("$jarJarTaskName").dependsOn classesJarTask, configurations.provided |
| |
| variant.packageLibrary.dependsOn "$jarJarTaskName" |
| } |
| |
| apply from: "$rootDir/javadoc.gradle" |
| apply from: "$rootDir/publishLocal.gradle" |