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 17apply plugin: 'java' 18 19sourceCompatibility = dataBindingConfig.javaSourceCompatibility 20targetCompatibility = dataBindingConfig.javaTargetCompatibility 21 22sourceSets { 23 main { 24 java { 25 srcDir 'src/main/java' 26 srcDir 'src/main/xml-gen' 27 srcDir 'src/main/grammar-gen' 28 } 29 } 30 test { 31 java { 32 srcDir 'src/test/java' 33 } 34 } 35 36} 37 38dependencies { 39 testCompile 'junit:junit:4.12' 40 compile project(':dataBinding:baseLibrary') 41 compile 'com.tunnelvisionlabs:antlr4:4.5' 42 compile 'commons-io:commons-io:2.4' 43 compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3' 44 compile 'com.google.guava:guava:17.0' 45} 46 47project.tasks.create(name : "generateXmlParser", type : JavaExec) { 48 classpath configurations.runtime 49 main "org.antlr.v4.Tool" 50 workingDir projectDir 51 args "XMLParser.g4", "-visitor", "-o", "src/main/java/android/databinding/parser", "-package", "android.databinding.parser", "-lib", "." 52} 53 54project.tasks.create(name : "generateGrammar", type : JavaExec) { 55 classpath configurations.runtime 56 main "org.antlr.v4.Tool" 57 args "BindingExpression.g4", "-visitor", "-o", "src/main/grammar-gen/android/databinding/parser", "-package", "android.databinding.parser" 58} 59 60tasks.create(name : 'exportBuildVersions') << { 61 def props = new HashMap(); 62 def buildVersionFile = new File(sourceSets.main.output.resourcesDir,"data_binding_version_info.properties") 63 // Using Java Properties appends date to the output which is bad for incremental compilation. 64 // Instead, we build it manually. 65 props.put("compilerCommon", project.version) 66 props.put("compiler", rootProject.findProject("dataBinding:compiler").version) 67 props.put("baseLibrary", rootProject.findProject("dataBinding:baseLibrary").version) 68 props.put("extensions", dataBindingConfig.extensionsVersion) 69 buildVersionFile.getParentFile().mkdirs() 70 println("writing build versions file to $buildVersionFile") 71 def propText = new StringBuilder(); 72 props.each { 73 propText.append(it.key).append("=").append(it.value).append(System.getProperty("line.separator")) 74 } 75 file(buildVersionFile).write(propText.toString()) 76} 77 78tasks['jar'].dependsOn('exportBuildVersions') 79tasks['exportBuildVersions'].dependsOn('processResources') 80 81project.ext.pomName = 'Data Binding Compiler Common' 82project.ext.pomDesc = 'Common library that can be shared between different build tools' 83enablePublishing(this, true) 84