Home | History | Annotate | Download | only in baseAdapters
      1 /*
      2  * Copyright (C) 2015 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 buildscript {
     17     dependencies {
     18         classpath "com.android.tools.build:gradle:${dataBindingConfig.androidPluginVersion}"
     19         // NOTE: Do not place your application dependencies here; they belong
     20         // in the individual module build.gradle files
     21     }
     22 }
     23 apply plugin: 'com.android.library'
     24 
     25 android {
     26     compileSdkVersion dataBindingConfig.compileSdkVersion
     27     buildToolsVersion dataBindingConfig.buildToolsVersion
     28     dataBinding {
     29         enabled = true
     30         addDefaultAdapters = false
     31     }
     32     defaultConfig {
     33         minSdkVersion 7
     34         targetSdkVersion 23
     35         versionCode 1
     36         versionName "1.0"
     37     }
     38     buildTypes {
     39         release {
     40             minifyEnabled false
     41             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
     42         }
     43     }
     44     compileOptions {
     45         sourceCompatibility dataBindingConfig.javaTargetCompatibility
     46         targetCompatibility dataBindingConfig.javaSourceCompatibility
     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     }
     53 }
     54 
     55 dependencies {
     56     provided 'com.android.support:support-v4:+'
     57     provided 'com.android.support:cardview-v7:+'
     58     provided 'com.android.support:appcompat-v7:+'
     59 }
     60 
     61 //create jar tasks
     62 android.libraryVariants.all { variant ->
     63     def name = variant.buildType.name
     64 
     65     if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
     66         return; // Skip debug builds.
     67     }
     68     def suffix = name.capitalize()
     69 
     70     def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
     71         source variant.javaCompile.source
     72         classpath = files(variant.javaCompile.classpath.files) + files(
     73                 "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
     74     }
     75 
     76     def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
     77         classifier = 'javadoc'
     78         from 'build/docs/javadoc'
     79     }
     80     javadocJarTask.dependsOn javadocTask
     81 
     82     def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
     83         classifier = 'sources'
     84         from android.sourceSets.main.java.srcDirs
     85     }
     86 
     87     artifacts.add('archives', javadocJarTask);
     88     artifacts.add('archives', sourcesJarTask);
     89 }
     90 
     91 uploadArchives {
     92     repositories {
     93         mavenDeployer {
     94             pom.artifactId = "adapters"
     95             pom.project {
     96                 licenses {
     97                     license {
     98                         name dataBindingConfig.licenseName
     99                         url dataBindingConfig.licenseUrl
    100                         distribution dataBindingConfig.licenseDistribution
    101                     }
    102                 }
    103             }
    104         }
    105     }
    106 }
    107 
    108 
    109 task prebuild(type : Copy) {
    110     dependsOn uploadArchives
    111     from "$buildDir/outputs/aar/baseAdapters-release.aar"
    112     into dataBindingConfig.prebuildFolder
    113     rename { String fileName ->
    114         "databinding-adapters.aar"
    115     }
    116 }