blob: b697534f92676cbdf012025212070e15d4d4e7b8 [file] [log] [blame]
Tor Norbye957c7742018-01-26 17:12:10 -08001buildscript {
Tor Norbyee5f47062018-07-18 18:43:51 -07002 ext.gradle_version = '3.2.0-beta05'
3 ext.studio_version = '26.2.0-beta05'
Tor Norbyee87c4322018-09-14 13:50:38 -07004 ext.kotlin_version = '1.2.70'
Tor Norbye957c7742018-01-26 17:12:10 -08005 repositories {
6 google()
7 jcenter()
8 }
9 dependencies {
10 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 classpath "com.android.tools.build:gradle:$gradle_version"
12 }
13}
14
Tor Norbye5f5d5ea2018-04-19 17:25:39 -070015repositories {
16 google()
17 jcenter()
18}
19
Tor Norbye957c7742018-01-26 17:12:10 -080020apply plugin: 'application'
21apply plugin: 'java'
22apply plugin: 'kotlin'
23apply plugin: 'maven'
24
25group = 'com.android'
Tor Norbyef7369f22018-02-27 11:06:46 -080026def versionPropertyFile = file('src/main/resources/version.properties')
27if (versionPropertyFile.canRead()) {
28 Properties versionProps = new Properties()
29 versionProps.load(new FileInputStream(versionPropertyFile))
30 version = versionProps['metalavaVersion']
31} else {
32 throw new FileNotFoundException("Could not read $versionPropertyFile")
33}
Tor Norbye957c7742018-01-26 17:12:10 -080034
35mainClassName = "com.android.tools.metalava.Driver"
36applicationDefaultJvmArgs = ["-ea", "-Xms2g", "-Xmx4g"]
37sourceCompatibility = 1.8
38
39compileKotlin {
40 sourceCompatibility = JavaVersion.VERSION_1_8
41 targetCompatibility = JavaVersion.VERSION_1_8
42
43 kotlinOptions {
44 jvmTarget = "1.8"
45 apiVersion = "1.2"
46 languageVersion = "1.2"
47 }
48}
49
Tor Norbye957c7742018-01-26 17:12:10 -080050dependencies {
51 implementation "com.android.tools.external.org-jetbrains:uast:$studio_version"
52 implementation "com.android.tools.external.com-intellij:intellij-core:$studio_version"
53 implementation "com.android.tools.lint:lint-api:$studio_version"
54 implementation "com.android.tools.lint:lint-checks:$studio_version"
55 implementation "com.android.tools.lint:lint-gradle:$studio_version"
56 implementation "com.android.tools.lint:lint:$studio_version"
Tor Norbye5f5d5ea2018-04-19 17:25:39 -070057 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
58 testImplementation "com.android.tools.lint:lint-tests:$studio_version"
Tor Norbye957c7742018-01-26 17:12:10 -080059 testImplementation 'junit:junit:4.11'
Tor Norbye957c7742018-01-26 17:12:10 -080060}
61
62// shadow jar: Includes all dependencies
63buildscript {
64 repositories {
65 jcenter()
66 }
67 dependencies {
68 classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
69 }
70}
71apply plugin: 'com.github.johnrengelman.shadow'
72shadowJar {
73 baseName = "metalava-$version-full-SNAPSHOT"
74 classifier = null
75 version = null
76 zip64 = true
77}
78
Tor Norbye5f229d72018-02-20 15:50:40 -080079defaultTasks 'clean', 'installDist'
Tor Norbye957c7742018-01-26 17:12:10 -080080
81/*
82 * With the build server you are given two env variables:
83 * 1. The OUT_DIR is a temporary directory you can use to put things during the build.
84 * 2. The DIST_DIR is where you want to save things from the build.
85 *
86 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
87 */
88if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
89 buildDir = file("${System.env.OUT_DIR}/host/common/metalava").getCanonicalFile()
90 ext.distDir = file(System.env.DIST_DIR).getCanonicalFile()
91 ext.distsDir = ext.distDir
92
93 // The distDir is conveniently named after the build ID.
94 version = "${version}.${ext.distDir.name}"
95} else {
96 buildDir = file('../../out/host/common')
97 ext.distDir = file('../../out/dist')
98 ext.distsDir = ext.distDir
99
100 // Local builds are not public release candidates.
101 version = "${version}-SNAPSHOT"
102}
103
Tor Norbye30527252018-03-05 16:32:28 -0800104// KtLint: https://github.com/shyiko/ktlint
105
106configurations {
107 ktlint
108}
109
110dependencies {
Tor Norbye34dea272018-09-07 14:54:01 -0700111 ktlint "com.github.shyiko:ktlint:0.28.0"
Tor Norbye30527252018-03-05 16:32:28 -0800112}
113
114task ktlint(type: JavaExec, group: "verification") {
115 description = "Check Kotlin code style."
116 main = "com.github.shyiko.ktlint.Main"
117 classpath = configurations.ktlint
118 args "src/**/*.kt"
119}
120check.dependsOn ktlint
121
122task format(type: JavaExec, group: "formatting") {
123 description = "Fix Kotlin code style deviations."
124 main = "com.github.shyiko.ktlint.Main"
125 classpath = configurations.ktlint
126 args "-F", "src/**/*.kt"
127}