| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 
 | apply plugin: 'java'
dependencies {
    compile project(':base:annotations')
}
group = 'com.android.tools.build'
archivesBaseName = 'builder-model'
version = rootProject.ext.buildVersion
project.ext.pomName = 'Android Builder Model library'
project.ext.pomDesc = 'Model for the Builder library.'
project.ext.apiVersion = rootProject.ext.apiVersion ?: 0
// because the model is passed from the IDE to Gradle, no matter
// what version of Gradle Plugin is running, we need to keep this
// as Java6 bytecode in case Studio 2.2 loads a project running
// an older plugin in a JDK6 VM.
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
["Model-Version": version, "Model-Api-Version": apiVersion].each { key, value ->
    jar.manifest.attributes((key): value)
}
def generated = new File("${project.buildDir}/generated/java")
sourceSets {
    main {
        java {
            srcDir generated
        }
    }
}
task generateVersionConstantsJava {
    inputs.property("apiVersion", apiVersion)
    inputs.property("version", version)
    ext.versionFile = new File(generated, "com/android/builder/model/Version.java")
    outputs.file(versionFile)
}
generateVersionConstantsJava << {
    versionFile.parentFile.mkdirs()
    versionFile.text = """
package com.android.builder.model;
public final class Version {
    private Version() {}
    public static final String ANDROID_GRADLE_PLUGIN_VERSION = "$version";
    public static final int BUILDER_MODEL_API_VERSION = $apiVersion;
}
"""
}
tasks.compileJava.dependsOn generateVersionConstantsJava
 |