[go: nahoru, domu]

build.gradle revision d8f45ed6a6b8a3061a08d929c232ad14582f56c5
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
17apply plugin: 'com.android.library'
18project.ext.addDataBindingAdapters = false
19apply plugin: 'com.android.databinding'
20
21android {
22    compileSdkVersion 21
23    buildToolsVersion "21.1.2"
24
25    defaultConfig {
26        minSdkVersion 7
27        targetSdkVersion 21
28        versionCode 1
29        versionName "1.0"
30    }
31    buildTypes {
32        release {
33            minifyEnabled false
34            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
35        }
36    }
37
38    packagingOptions {
39        exclude 'META-INF/services/javax.annotation.processing.Processor'
40        exclude 'META-INF/LICENSE.txt'
41        exclude 'META-INF/NOTICE.txt'
42    }
43}
44
45dependencies {
46    // TODO make these provided when gradle build supports them
47    // see: https://code.google.com/p/android/issues/detail?id=149268
48    compile 'com.android.support:support-v4:+'
49    compile 'com.android.support:cardview-v7:+'
50    compile 'com.android.support:appcompat-v7:+'
51}
52
53configurations {
54    jarArchives
55}
56
57//create jar tasks
58android.libraryVariants.all { variant ->
59    def name = variant.buildType.name
60
61    if (name.equals(com.android.builder.core.BuilderConstants.DEBUG)) {
62        return; // Skip debug builds.
63    }
64    def suffix = name.capitalize()
65    // @Jar version is needed to run compiler tests
66    def jarTask = project.tasks.create "jar${suffix}", Jar
67    jarTask.dependsOn variant.javaCompile
68    jarTask.from variant.javaCompile.destinationDir
69    def packageName = "com.android.databinding.library.baseAdapters"
70    def appPkgAsClass = packageName.replace('.', '/')
71    jarTask.exclude("android/databinding/layouts/*.*")
72    jarTask.exclude("$appPkgAsClass/databinding/*")
73    jarTask.exclude("$appPkgAsClass/BR.*")
74    artifacts.add('jarArchives', jarTask);
75
76    def javadocTask = project.tasks.create(name: "javadoc${suffix}", type: Javadoc) {
77        source variant.javaCompile.source
78        exclude("android/databinding/layouts/*.*")
79        exclude("$appPkgAsClass/databinding/*")
80        exclude("$appPkgAsClass/BR.*")
81        exclude("$appPkgAsClass/R.*")
82        exclude("$appPkgAsClass/BuildConfig.*")
83        classpath = files(variant.javaCompile.classpath.files) + files(
84                "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")
85    }
86
87    def javadocJarTask = project.tasks.create(name: "javadocJar${suffix}", type: Jar) {
88        classifier = 'javadoc'
89        from 'build/docs/javadoc'
90    }
91    javadocJarTask.dependsOn javadocTask
92
93    def sourcesJarTask = project.tasks.create(name: "sourceJar${suffix}", type: Jar) {
94        classifier = 'sources'
95        from android.sourceSets.main.java.srcDirs
96    }
97
98    artifacts.add('jarArchives', javadocJarTask);
99    artifacts.add('jarArchives', sourcesJarTask);
100}
101
102uploadArchives {
103}
104
105uploadJarArchives {
106    repositories {
107        mavenDeployer {
108            repository(url: "file://${config.mavenRepoDir}")
109            pom.artifactId = "adapters"
110            pom.whenConfigured {
111                println("configured pom, $it")
112                it.dependencies.clear()
113            }
114            pom.project {
115                licenses {
116                    license {
117                        name config.licenseName
118                        url config.licenseUrl
119                        distribution config.licenseDistribution
120                    }
121                }
122            }
123        }
124    }
125}
126
127uploadArchives.dependsOn uploadJarArchives
128task prebuild(type : Copy) {
129    dependsOn uploadArchives
130    from "$buildDir/outputs/aar/baseAdapters-release.aar"
131    into config.prebuildFolder
132    rename { String fileName ->
133        "databinding-adapters.aar"
134    }
135}