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