blob: 729342a2f6d344c21f787f6eac1768fce45b9ed7 [file] [log] [blame]
/*
* 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'
}
}
}
// The libs object comes from buildSrc/base/version.gradle
dependencies {
compile project(':dataBinding:baseLibrary')
compile libs.antlr4
compile libs.apache_commons_io
compile libs.juniversalchardet
compile libs.guava
compile 'com.android.tools:annotations:24.5.0'
testCompile libs.junit
}
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').doLast {
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()
logger.info("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)