Tor Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 1 | buildscript { |
Tor Norbye | e5f4706 | 2018-07-18 18:43:51 -0700 | [diff] [blame] | 2 | ext.gradle_version = '3.2.0-beta05' |
| 3 | ext.studio_version = '26.2.0-beta05' |
Tor Norbye | e87c432 | 2018-09-14 13:50:38 -0700 | [diff] [blame] | 4 | ext.kotlin_version = '1.2.70' |
Tor Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 5 | 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 Norbye | 5f5d5ea | 2018-04-19 17:25:39 -0700 | [diff] [blame] | 15 | repositories { |
| 16 | google() |
| 17 | jcenter() |
| 18 | } |
| 19 | |
Tor Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 20 | apply plugin: 'application' |
| 21 | apply plugin: 'java' |
| 22 | apply plugin: 'kotlin' |
| 23 | apply plugin: 'maven' |
| 24 | |
| 25 | group = 'com.android' |
Tor Norbye | f7369f2 | 2018-02-27 11:06:46 -0800 | [diff] [blame] | 26 | def versionPropertyFile = file('src/main/resources/version.properties') |
| 27 | if (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 Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 34 | |
| 35 | mainClassName = "com.android.tools.metalava.Driver" |
| 36 | applicationDefaultJvmArgs = ["-ea", "-Xms2g", "-Xmx4g"] |
| 37 | sourceCompatibility = 1.8 |
| 38 | |
| 39 | compileKotlin { |
| 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 Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 50 | dependencies { |
| 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 Norbye | 5f5d5ea | 2018-04-19 17:25:39 -0700 | [diff] [blame] | 57 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" |
| 58 | testImplementation "com.android.tools.lint:lint-tests:$studio_version" |
Tor Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 59 | testImplementation 'junit:junit:4.11' |
Tor Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | // shadow jar: Includes all dependencies |
| 63 | buildscript { |
| 64 | repositories { |
| 65 | jcenter() |
| 66 | } |
| 67 | dependencies { |
| 68 | classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2' |
| 69 | } |
| 70 | } |
| 71 | apply plugin: 'com.github.johnrengelman.shadow' |
| 72 | shadowJar { |
| 73 | baseName = "metalava-$version-full-SNAPSHOT" |
| 74 | classifier = null |
| 75 | version = null |
| 76 | zip64 = true |
| 77 | } |
| 78 | |
Tor Norbye | 5f229d7 | 2018-02-20 15:50:40 -0800 | [diff] [blame] | 79 | defaultTasks 'clean', 'installDist' |
Tor Norbye | 957c774 | 2018-01-26 17:12:10 -0800 | [diff] [blame] | 80 | |
| 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 | */ |
| 88 | if (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 Norbye | 3052725 | 2018-03-05 16:32:28 -0800 | [diff] [blame] | 104 | // KtLint: https://github.com/shyiko/ktlint |
| 105 | |
| 106 | configurations { |
| 107 | ktlint |
| 108 | } |
| 109 | |
| 110 | dependencies { |
Tor Norbye | 34dea27 | 2018-09-07 14:54:01 -0700 | [diff] [blame] | 111 | ktlint "com.github.shyiko:ktlint:0.28.0" |
Tor Norbye | 3052725 | 2018-03-05 16:32:28 -0800 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | task 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 | } |
| 120 | check.dependsOn ktlint |
| 121 | |
| 122 | task 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 | } |