summaryrefslogtreecommitdiff
path: root/compilerCommon/build.gradle
blob: 0f260e48a7206e19790fc732f543b93a7fbada33 (plain)
1
2
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'java'

sourceSets {
    main {
        java {
            srcDir 'src/main/java'
            srcDir 'src/main/xml-gen'
            srcDir 'src/main/grammar-gen'
        }
    }
    test {
        java {
            srcDir 'src/test/java'
        }
    }

}

dependencies {
    testCompile 'junit:junit:4.12'
    compile project(':dataBinding:baseLibrary')
    compile 'org.antlr:antlr4:4.5.3'
    compile 'commons-io:commons-io:2.4'
    compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'
    compile 'com.google.guava:guava:17.0'
    compile 'com.android.tools:annotations:24.5.0'
}

project.tasks.create(name : "generateXmlLexer", type : JavaExec) {
    classpath configurations.runtime
    main "org.antlr.v4.Tool"
    workingDir projectDir
    args "XMLLexer.g4", "-visitor", "-lib", projectDir.absolutePath, "-o", "src/main/xml-gen/android/databinding/parser", "-package", "android.databinding.parser"
}

project.tasks.create(name : "generateXmlParser", type : JavaExec) {
    classpath configurations.runtime
    main "org.antlr.v4.Tool"
    workingDir projectDir
    args "XMLParser.g4", "-visitor", "-lib", projectDir.absolutePath, "-o", "src/main/xml-gen/android/databinding/parser", "-package", "android.databinding.parser"
    dependsOn "generateXmlLexer"
}

project.tasks.create(name : "generateGrammar", type : JavaExec) {
    classpath configurations.runtime
    main "org.antlr.v4.Tool"
    args "BindingExpression.g4", "-visitor", "-o", "src/main/grammar-gen/android/databinding/parser", "-package", "android.databinding.parser"
}

tasks.create(name : 'exportBuildVersions') << {
    def props = new HashMap();
    def buildVersionFile = new File(sourceSets.main.output.resourcesDir,"data_binding_version_info.properties")
    // Using Java Properties appends date to the output which is bad for incremental compilation.
    // Instead, we build it manually.
    props.put("compilerCommon", project.version)
    props.put("compiler", rootProject.findProject("dataBinding:compiler").version)
    props.put("baseLibrary", rootProject.findProject("dataBinding:baseLibrary").version)
    props.put("extensions", dataBindingConfig.extensionsVersion)
    buildVersionFile.getParentFile().mkdirs()
    println("writing build versions file to $buildVersionFile")
    def propText = new StringBuilder();
    props.each {
        propText.append(it.key).append("=").append(it.value).append(System.getProperty("line.separator"))
    }
    file(buildVersionFile).write(propText.toString())
}

tasks['jar'].dependsOn('exportBuildVersions')
tasks['exportBuildVersions'].dependsOn('processResources')

project.ext.pomName = 'Data Binding Compiler Common'
project.ext.pomDesc = 'Common library that can be shared between different build tools'
enablePublishing(this, true)