• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1apply plugin: 'com.android.library'
2
3archivesBaseName = 'recommendation'
4
5dependencies {
6    compile project(':support-v4')
7}
8
9android {
10    compileSdkVersion project.ext.currentSdk
11
12    defaultConfig {
13        minSdkVersion 21
14    }
15
16    sourceSets {
17        main.manifest.srcFile 'AndroidManifest.xml'
18        main.java.srcDirs = ['src']
19        main.res.srcDir 'res'
20        main.assets.srcDir 'assets'
21        main.resources.srcDir 'src'
22
23        // this moves src/instrumentTest to tests so all folders follow:
24        // tests/java, tests/res, tests/assets, ...
25        // This is a *reset* so it replaces the default paths
26        androidTest.setRoot('tests')
27        androidTest.java.srcDir 'tests/src'
28    }
29
30    compileOptions {
31        sourceCompatibility JavaVersion.VERSION_1_7
32        targetCompatibility JavaVersion.VERSION_1_7
33    }
34}
35
36android.libraryVariants.all { variant ->
37    def name = variant.buildType.name
38
39    if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
40        return; // Skip debug builds.
41    }
42    def suffix = name.capitalize()
43
44    def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){
45        dependsOn variant.javaCompile
46        from variant.javaCompile.destinationDir
47        from 'LICENSE.txt'
48    }
49    def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
50        source android.sourceSets.main.java
51        classpath = files(variant.javaCompile.classpath.files) + files(
52                "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
53    }
54
55    def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
56        classifier = 'javadoc'
57        from 'build/docs/javadoc'
58    }
59
60    def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
61        classifier = 'sources'
62        from android.sourceSets.main.java.srcDirs
63    }
64
65    artifacts.add('archives', javadocJarTask);
66    artifacts.add('archives', sourcesJarTask);
67}
68