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