Home | History | Annotate | Download | only in metalava
      1 buildscript {
      2     ext.gradle_version = '3.2.0-alpha16'
      3     ext.studio_version = '26.2.0-alpha16'
      4     ext.kotlin_version = '1.2.41'
      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 
     15 repositories {
     16     google()
     17     jcenter()
     18 }
     19 
     20 apply plugin: 'application'
     21 apply plugin: 'java'
     22 apply plugin: 'kotlin'
     23 apply plugin: 'maven'
     24 
     25 group = 'com.android'
     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 }
     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 
     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"
     57     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
     58     testImplementation "com.android.tools.lint:lint-tests:$studio_version"
     59     testImplementation 'junit:junit:4.11'
     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 
     79 defaultTasks 'clean', 'installDist'
     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 
    104 // KtLint: https://github.com/shyiko/ktlint
    105 
    106 configurations {
    107     ktlint
    108 }
    109 
    110 dependencies {
    111     ktlint "com.github.shyiko:ktlint:0.23.1"
    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 }
    128