1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*
* 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-library'
apply plugin: 'kotlin'
sourceCompatibility = dataBindingConfig.compilerJavaTargetCompatibility
targetCompatibility = dataBindingConfig.compilerJavaSourceCompatibility
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 {
implementation project(':dataBinding:baseLibrary')
implementation project(':dataBinding:baseLibrarySupport')
implementation libs.antlr4
implementation libs.apache_commons_io
implementation libs.juniversalchardet
implementation libs.guava
implementation libs.javapoet
implementation libs.kotlin_stdlib
implementation libs.gson
// specify a jaxb runtime for j11 compatibility
implementation libs.jaxb_runtime
implementation libs.com.android.tools.annotations
implementation 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.runtimeClasspath
mainClass.set("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.runtimeClasspath
mainClass.set("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.runtimeClasspath
mainClass.set("org.antlr.v4.Tool")
args "BindingExpression.g4", "-visitor", "-o", "src/main/grammar-gen/android/databinding/parser", "-package", "android.databinding.parser"
}
def versionProvider = project.provider { project.version }
def buildVersionFileProvider = project.provider { project.file(new File(sourceSets.main.output.resourcesDir,"data_binding_version_info.properties")) }
tasks.create(name : 'exportBuildVersions').doLast {
def props = new HashMap();
def buildVersionFile = buildVersionFileProvider.get()
// Using Java Properties appends date to the output which is bad for incremental compilation.
// Instead, we build it manually.
props.put("compilerCommon", versionProvider.get())
props.put("compiler", versionProvider.get())
props.put("baseLibrary", versionProvider.get())
props.put("extensions", versionProvider.get())
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"))
}
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'
if (!dataBindingConfig.isIndependent) {
enablePublishing(this, true)
publishing {
publications {
withType(MavenPublication) {
artifactId = 'databinding-compiler-common'
}
}
}
}
|