blob: ad5e88029928872ad5b64e5718e7e519d90df19f [file] [log] [blame]
buildscript {
ext.gradle_version = '3.4.0-beta01'
ext.studio_version = '26.4.0-beta01'
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:$gradle_version"
}
}
repositories {
google()
jcenter()
}
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'maven'
group = 'com.android'
def versionPropertyFile = file('src/main/resources/version.properties')
if (versionPropertyFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropertyFile))
version = versionProps['metalavaVersion']
} else {
throw new FileNotFoundException("Could not read $versionPropertyFile")
}
mainClassName = "com.android.tools.metalava.Driver"
applicationDefaultJvmArgs = ["-ea", "-Xms2g", "-Xmx4g"]
sourceCompatibility = 1.8
compileKotlin {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = "1.8"
apiVersion = "1.3"
languageVersion = "1.3"
}
}
dependencies {
implementation "com.android.tools.external.org-jetbrains:uast:$studio_version"
implementation "com.android.tools.external.com-intellij:intellij-core:$studio_version"
implementation "com.android.tools.lint:lint-api:$studio_version"
implementation "com.android.tools.lint:lint-checks:$studio_version"
implementation "com.android.tools.lint:lint-gradle:$studio_version"
implementation "com.android.tools.lint:lint:$studio_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation "com.android.tools.lint:lint-tests:$studio_version"
testImplementation 'junit:junit:4.11'
}
// shadow jar: Includes all dependencies
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
shadowJar {
baseName = "metalava-$version-full-SNAPSHOT"
classifier = null
version = null
zip64 = true
}
defaultTasks 'clean', 'installDist'
/*
* With the build server you are given two env variables:
* 1. The OUT_DIR is a temporary directory you can use to put things during the build.
* 2. The DIST_DIR is where you want to save things from the build.
*
* The build server will copy the contents of DIST_DIR to somewhere and make it available.
*/
if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
buildDir = file("${System.env.OUT_DIR}/host/common/metalava").getCanonicalFile()
ext.distDir = file(System.env.DIST_DIR).getCanonicalFile()
ext.distsDir = ext.distDir
// The distDir is conveniently named after the build ID.
version = "${version}.${ext.distDir.name}"
} else {
buildDir = file('../../out/host/common')
ext.distDir = file('../../out/dist')
ext.distsDir = ext.distDir
// Local builds are not public release candidates.
version = "${version}-SNAPSHOT"
}
// KtLint: https://github.com/shyiko/ktlint
configurations {
ktlint
}
dependencies {
ktlint "com.github.shyiko:ktlint:0.30.0"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
}
check.dependsOn ktlint
task format(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
main = "com.github.shyiko.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}