blob: baee4f4346b4628a45c30863a073bb07b2a676af [file] [log] [blame]
Yigit Boyar19b41102016-11-20 10:46:32 -08001/*
2 * Copyright (C) 2016 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 */
16def root = ext.lifecyclesRootFolder
17ext.prebuiltsRoot = "file://${root}/../../../prebuilts"
18ext.repoNames = ["$prebuiltsRoot/maven_repo",
19 "$prebuiltsRoot/gradle-plugin",
20 "$prebuiltsRoot/tools/common/m2/repository",
21 "$prebuiltsRoot/tools/common/m2/internal",
22 "$prebuiltsRoot/tools/common/offline-m2",
23 "$prebuiltsRoot/maven_repo/android",
24 "$prebuiltsRoot/../out/host/gradle/frameworks/support/build/support_repo/"]
25
26ext.kotlin_version = "1.0.5"
Yigit Boyar2259e4d2016-11-25 18:26:10 -080027ext.android_gradle_plugin_version = "2.2.1"
Yigit Boyar19b41102016-11-20 10:46:32 -080028ext.auto_common_version = "0.6"
29ext.javapoet_version = "1.7.0"
30ext.compile_testing_version = "0.9"
31ext.localize_maven_version = "1.1"
32ext.support_lib_version = "25.1.0-SNAPSHOT"
33ext.junit_version = "4.12"
34ext.mockito_version = "1.9.5"
35ext.min_sdk_version = 14
36ext.target_sdk_version = 24
37ext.compile_sdk_version = 24
38ext.build_tools_version = "24.0.0"
39ext.intellij_annotation = "12.0"
Sergey Vasilinetsb085e342016-12-05 19:02:59 -080040ext.release_version = "1.0-SNAPSHOT"
Yigit Boyar19b41102016-11-20 10:46:32 -080041ext.enablePublicRepos = System.getenv("ALLOW_PUBLIC_REPOS")
42
43def addRepos(RepositoryHandler handler) {
44 repoNames.each { repo ->
45 handler.maven {
46 url repo
47 }
48 if (ext.enablePublicRepos) {
49 handler.mavenCentral()
50 handler.jcenter()
51 }
52 }
53}
54
55def createKotlinCheckstyle(Project project) {
56 def kotlinCheckstyle = project.tasks.create(name : 'checkstyleKotlin', type: Checkstyle) {
Sergey Vasilinetsb085e342016-12-05 19:02:59 -080057 configFile file("$lifecyclesRootFolder/../flatfoot-common/kotlin-checkstyle.xml")
Yigit Boyar19b41102016-11-20 10:46:32 -080058 source project.sourceSets.main.allJava
Yigit Boyarde33ce42016-11-24 11:52:24 -080059 source project.sourceSets.test.allJava
Yigit Boyar19b41102016-11-20 10:46:32 -080060 ignoreFailures false
61 showViolations true
62 include '**/*.kt'
63 classpath = project.files()
Sergey Vasilinetsb085e342016-12-05 19:02:59 -080064 checkstyleClasspath = files(file("$lifecyclesRootFolder../../../development/tools/checkstyle/checkstyle.jar").path)
65 }
Yigit Boyar19b41102016-11-20 10:46:32 -080066 project.tasks.findByName("check").dependsOn(kotlinCheckstyle)
67 // poor man's line length check
68 def lineCheck = project.tasks.create(name : "lineLengthCheck") {
Yigit Boyarde33ce42016-11-24 11:52:24 -080069 (project.sourceSets.main.allJava.getSourceDirectories() +
70 project.sourceSets.test.allJava.getSourceDirectories()).each { sourceDir ->
71 fileTree(dir : sourceDir, include : "**/*.kt").each{ file ->
72 file.readLines().eachWithIndex { line, index ->
73 if (line.size() > 100) {
Yigit Boyarefaf86a2016-12-02 15:16:35 -080074 throw new Exception("line too long: file: $file line:$index line: $line")
Yigit Boyarde33ce42016-11-24 11:52:24 -080075 }
76 }
77 }
Yigit Boyar19b41102016-11-20 10:46:32 -080078 }
79 }
80 kotlinCheckstyle.dependsOn(lineCheck)
81}
82
83def createAndroidCheckstyle(Project project) {
84 def androidCheckstyle = project.tasks.create(name : 'checkstyleAndroid', type: Checkstyle) {
Sergey Vasilinetsb085e342016-12-05 19:02:59 -080085 configFile file("$lifecyclesRootFolder/../../../development/tools/checkstyle/android-style.xml")
Yigit Boyara034a6e2016-11-25 08:57:33 -080086 if (project.hasProperty('android')) {
87 source project.android.sourceSets.main.java.getSrcDirs()
88 }
89 if (project.sourceSets.hasProperty('main')) {
90 source project.sourceSets.main.allJava
91 }
Yigit Boyar19b41102016-11-20 10:46:32 -080092 ignoreFailures false
93 showViolations true
94 include '**/*.java'
95 classpath = project.files()
Sergey Vasilinetsb085e342016-12-05 19:02:59 -080096 checkstyleClasspath = files(file("$lifecyclesRootFolder/../../../development/tools/checkstyle/checkstyle.jar").path)
Yigit Boyar19b41102016-11-20 10:46:32 -080097 }
98 project.tasks.findByName("check").dependsOn(androidCheckstyle)
99}
100
101ext.localMavenRepo = "file://${new File(root, "maven-repo").absolutePath}"
102ext.addRepos = this.&addRepos
103ext.createKotlinCheckstyle = this.&createKotlinCheckstyle
104ext.createAndroidCheckstyle = this.&createAndroidCheckstyle