| 1 |
/* |
| 2 |
* Copyright (C) 2015 The Android Open Source Project |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
apply plugin: 'java' |
| 18 |
|
| 19 |
sourceSets { |
| 20 |
main { |
| 21 |
java { |
| 22 |
srcDir 'src/main/java' |
| 23 |
srcDir 'src/main/xml-gen' |
| 24 |
srcDir 'src/main/grammar-gen' |
| •25 |
srcDir "${rootDir}/debian/antlr4" |
| 26 |
} |
| 27 |
} |
| 28 |
test { |
| 29 |
java { |
| 30 |
srcDir 'src/test/java' |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
dependencies { |
| 37 |
testCompile 'junit:junit:4.12' |
| 38 |
compile project(':dataBinding:baseLibrary') |
| 39 |
compile 'org.antlr:antlr4:4.5.3' |
| 40 |
compile 'commons-io:commons-io:2.4' |
| 41 |
compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3' |
| 42 |
compile 'com.google.guava:guava:17.0' |
| 43 |
compile 'com.android.tools:annotations:24.5.0' |
| •44 |
compile 'javax.xml.bind:jaxb-api:debian' |
| 45 |
} |
| 46 |
|
| 47 |
project.tasks.create(name : "generateXmlLexer", type : JavaExec) { |
| 48 |
classpath configurations.runtime |
| 49 |
main "org.antlr.v4.Tool" |
| 50 |
workingDir projectDir |
| 51 |
args "XMLLexer.g4", "-visitor", "-lib", projectDir.absolutePath, "-o", "src/main/xml-gen/android/databinding/parser", "-package", "android.databinding.parser" |
| 52 |
} |
| 53 |
|
| 54 |
project.tasks.create(name : "generateXmlParser", type : JavaExec) { |
| 55 |
classpath configurations.runtime |
| 56 |
main "org.antlr.v4.Tool" |
| 57 |
workingDir projectDir |
| 58 |
args "XMLParser.g4", "-visitor", "-lib", projectDir.absolutePath, "-o", "src/main/xml-gen/android/databinding/parser", "-package", "android.databinding.parser" |
| 59 |
dependsOn "generateXmlLexer" |
| 60 |
} |
| 61 |
|
| 62 |
project.tasks.create(name : "generateGrammar", type : JavaExec) { |
| 63 |
classpath configurations.runtime |
| 64 |
main "org.antlr.v4.Tool" |
| 65 |
args "BindingExpression.g4", "-visitor", "-o", "src/main/grammar-gen/android/databinding/parser", "-package", "android.databinding.parser" |
| 66 |
} |
| 67 |
|
| 68 |
tasks.create(name : 'exportBuildVersions') << { |
| 69 |
def props = new HashMap(); |
| 70 |
def buildVersionFile = new File(sourceSets.main.output.resourcesDir,"data_binding_version_info.properties") |
| 71 |
// Using Java Properties appends date to the output which is bad for incremental compilation. |
| 72 |
// Instead, we build it manually. |
| 73 |
props.put("compilerCommon", project.version) |
| •74 |
props.put("compiler", project.version) |
| 75 |
props.put("baseLibrary", rootProject.findProject("dataBinding:baseLibrary").version) |
| 76 |
props.put("extensions", dataBindingConfig.extensionsVersion) |
| 77 |
buildVersionFile.getParentFile().mkdirs() |
| 78 |
println("writing build versions file to $buildVersionFile") |
| 79 |
def propText = new StringBuilder(); |
| 80 |
props.each { |
| 81 |
propText.append(it.key).append("=").append(it.value).append(System.getProperty("line.separator")) |
| 82 |
} |
| 83 |
file(buildVersionFile).write(propText.toString()) |
| 84 |
} |
| 85 |
|
| 86 |
tasks['jar'].dependsOn('exportBuildVersions') |
| 87 |
tasks['exportBuildVersions'].dependsOn('processResources') |
| 88 |
|
| 89 |
project.ext.pomName = 'Data Binding Compiler Common' |
| •90 |
project.ext.pomDesc = 'Common library that can be shared between different build tools' |