SupportLibraryExtension.kt revision 526389b5eb93f99eaf4dba0b0c75b0b7df9a0f65
1/*
2 * Copyright 2018 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
17package androidx.build
18
19import androidx.build.SupportConfig.DEFAULT_MIN_SDK_VERSION
20import groovy.lang.Closure
21import org.gradle.api.Project
22import java.util.ArrayList
23
24/**
25 * Extension for [SupportAndroidLibraryPlugin] and [SupportJavaLibraryPlugin].
26 */
27open class SupportLibraryExtension(val project: Project) {
28    var name: String? = null
29    var mavenVersion: Version? = null
30    var mavenGroup: String? = null
31    var description: String? = null
32    var inceptionYear: String? = null
33    var url = SUPPORT_URL
34    private var licenses: MutableCollection<License> = ArrayList()
35    var java8Library = false
36    var publish = false
37    /**
38     * This flag works only if publish flag is "true".
39     * It is useful for modules that are used for tooling. For example room annotation
40     * processor module is published, but we don't want to expose any docs, because we don't
41     * support using it as a library.
42     */
43    var generateDocs = true
44    /**
45     * If unset minSdkVersion will be [DEFAULT_MIN_SDK_VERSION].
46     */
47    var minSdkVersion: Int = DEFAULT_MIN_SDK_VERSION
48
49    fun license(closure: Closure<*>): License {
50        val license = project.configure(License(), closure) as License
51        licenses.add(license)
52        return license
53    }
54
55    fun getLicenses(): Collection<License> {
56        return licenses
57    }
58
59    companion object {
60        @JvmField
61        val ARCHITECTURE_URL
62                = "https://developer.android.com/topic/libraries/architecture/index.html"
63        @JvmField
64        val SUPPORT_URL = "http://developer.android.com/tools/extras/support-library.html"
65    }
66}
67
68class License {
69    var name: String? = null
70    var url: String? = null
71}