Home | History | Annotate | Download | only in library
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 // Top-level build file where you can add configuration options common to all sub-projects/modules.
     18 
     19 buildscript {
     20     dependencies {
     21         classpath "com.android.tools.build:gradle:${config.androidPluginVersion}"
     22         // NOTE: Do not place your application dependencies here; they belong
     23         // in the individual module build.gradle files
     24     }
     25 }
     26 
     27 apply plugin: 'com.android.library'
     28 
     29 android {
     30     compileSdkVersion 21
     31     buildToolsVersion "21.1"
     32 
     33     defaultConfig {
     34         minSdkVersion 7
     35         targetSdkVersion 21
     36         versionCode 1
     37         versionName "1.0"
     38     }
     39     compileOptions {
     40         sourceCompatibility JavaVersion.VERSION_1_7
     41         targetCompatibility JavaVersion.VERSION_1_7
     42     }
     43     buildTypes {
     44         release {
     45             minifyEnabled false
     46         }
     47     }
     48     packagingOptions {
     49         exclude 'META-INF/services/javax.annotation.processing.Processor'
     50         exclude 'META-INF/LICENSE.txt'
     51         exclude 'META-INF/NOTICE.txt'
     52         exclude 'android/databinding/DataBinderMapper.class'
     53     }
     54 }
     55 
     56 configurations {
     57     jarArchives
     58 }
     59 
     60 
     61 dependencies {
     62     compile 'com.android.support:support-v4:21.0.3'
     63     compile project(':baseLibrary')
     64 }
     65 
     66 //create jar tasks
     67 android.libraryVariants.all { variant ->
     68     def name = variant.buildType.name
     69 
     70     if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
     71         return; // Skip debug builds.
     72     }
     73     def suffix = name.capitalize()
     74 
     75     def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
     76         source variant.javaCompile.source + project(":baseLibrary").tasks['compileJava'].source
     77         classpath = files(variant.javaCompile.classpath.files) + files(
     78                 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
     79     }
     80 
     81     def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
     82         classifier = 'javadoc'
     83         from 'build/docs/javadoc'
     84     }
     85     javadocJarTask.dependsOn javadocTask
     86 
     87     def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
     88         classifier = 'sources'
     89         from android.sourceSets.main.java.srcDirs + project(":baseLibrary").sourceSets.main.java.srcDirs
     90     }
     91 
     92     artifacts.add('archives', javadocJarTask);
     93     artifacts.add('archives', sourcesJarTask);
     94 }
     95 uploadArchives {
     96     repositories {
     97         mavenDeployer {
     98             pom.artifactId = 'library'
     99             pom.project {
    100                 licenses {
    101                     license {
    102                         name config.licenseName
    103                         url config.licenseUrl
    104                         distribution config.licenseDistribution
    105                     }
    106                 }
    107             }
    108         }
    109     }
    110 }
    111 
    112 
    113 afterEvaluate {
    114     tasks['packageReleaseJar'].exclude('android/databinding/DataBinderMapper.*')
    115     tasks['packageReleaseJar'].exclude('android/databinding/DataBindingComponent.*')
    116     tasks['packageDebugJar'].exclude('android/databinding/DataBinderMapper.*')
    117     tasks['packageDebugJar'].exclude('android/databinding/DataBindingComponent.*')
    118 }
    119 
    120 task prebuildAar(type : Copy) {
    121     dependsOn uploadArchives
    122     from "$buildDir/outputs/aar/library-release.aar"
    123     into config.prebuildFolder
    124     rename { String fileName ->
    125         "databinding-library.aar"
    126     }
    127 }