1 apply plugin: 'com.android.library' 2 3 archivesBaseName = 'recommendation' 4 5 dependencies { 6 compile project(':support-v4') 7 } 8 9 android { 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 lintOptions { 31 abortOnError false 32 } 33 34 compileOptions { 35 sourceCompatibility JavaVersion.VERSION_1_7 36 targetCompatibility JavaVersion.VERSION_1_7 37 } 38 } 39 40 android.libraryVariants.all { variant -> 41 def name = variant.buildType.name 42 43 if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) { 44 return; // Skip debug builds. 45 } 46 def suffix = name.capitalize() 47 48 def jarTask = project.tasks.create(name: "jar${suffix}", type: Jar){ 49 dependsOn variant.javaCompile 50 from variant.javaCompile.destinationDir 51 from 'LICENSE.txt' 52 } 53 def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) { 54 source android.sourceSets.main.java 55 classpath = files(variant.javaCompile.classpath.files) + files( 56 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar") 57 } 58 59 def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) { 60 classifier = 'javadoc' 61 from 'build/docs/javadoc' 62 } 63 64 def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) { 65 classifier = 'sources' 66 from android.sourceSets.main.java.srcDirs 67 } 68 69 artifacts.add('archives', javadocJarTask); 70 artifacts.add('archives', sourcesJarTask); 71 } 72