| /* |
| * 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' |
| |
| sourceCompatibility = dataBindingConfig.javaSourceCompatibility |
| targetCompatibility = dataBindingConfig.javaTargetCompatibility |
| |
| 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 'com.tunnelvisionlabs:antlr4:4.5' |
| compile 'commons-io:commons-io:2.4' |
| compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3' |
| compile 'com.google.guava:guava:17.0' |
| } |
| |
| project.tasks.create(name : "generateXmlParser", type : JavaExec) { |
| classpath configurations.runtime |
| main "org.antlr.v4.Tool" |
| workingDir projectDir |
| args "XMLParser.g4", "-visitor", "-o", "src/main/java/android/databinding/parser", "-package", "android.databinding.parser", "-lib", "." |
| } |
| |
| 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) |