| /* | |
| * 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. | |
| */ | |
| import org.gradle.internal.jvm.Jvm | |
| apply plugin: 'java' | |
| apply plugin: 'kotlin' | |
| buildscript { | |
| dependencies { | |
| classpath libs.kotlin_gradle_plugin | |
| } | |
| } | |
| sourceSets { | |
| main { | |
| java { | |
| srcDir 'src/main/kotlin' | |
| srcDir 'src/main/java' | |
| srcDir 'src/main/xml-gen' | |
| srcDir 'src/main/grammar-gen' | |
| } | |
| } | |
| test { | |
| java { | |
| srcDir 'src/test/java' | |
| srcDir 'src/test/kotlin' | |
| } | |
| } | |
| } | |
| // The libs object comes from buildSrc/base/version.gradle | |
| dependencies { | |
| compile project(':dataBinding:baseLibrary') | |
| compile project(':dataBinding:baseLibrarySupport') | |
| compile libs.antlr4 | |
| compile libs.apache_commons_io | |
| compile libs.juniversalchardet | |
| compile libs.guava | |
| compile libs.javapoet | |
| compile libs.kotlin_stdlib | |
| compile libs.gson | |
| // specify a jaxb runtime for j11 compatibility | |
| compile libs.jaxb_runtime | |
| compile findProject(':base:annotations') ?: 'com.android.tools:annotations:24.5.0' | |
| compile libs.jetifier_core | |
| testImplementation libs.junit | |
| testImplementation libs.compile_testing | |
| testImplementation libs.truth | |
| if (!Jvm.current().javaVersion.isJava9Compatible()) { | |
| testImplementation files(Jvm.current().getToolsJar()) | |
| } | |
| } | |
| 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", project.version) | |
| props.put("baseLibrary", project.version) | |
| props.put("extensions", project.version) | |
| 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') | |
| archivesBaseName = "databinding-compiler-common" | |
| project.ext.pomName = 'Data Binding Compiler Common' | |
| project.ext.pomDesc = 'Common library that can be shared between different build tools' | |
| enablePublishing(this, true) |