Declare inputs and outputs in code-generation tasks

This makes such tasks work with Gradle's incremental build.

In practice this change is not very useful:
- The Dagger annotation processor version we use is not fully
  compatible with Gradle incremental build, and currently causes
  unnecessary rebuild in the util package, and forces tests to always run.
  Will try the latest version later, which claims to support incremental
  build.
- AppEngine deploy task leaves behind non-writable tools.jar files.
  Reruns of any builds that include :services:*:explodeWar would fail,
  and the easiest work-around right now is to run Gradle clean task.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=232929552
This commit is contained in:
weiminyu 2019-02-07 13:03:54 -08:00 committed by Gus Brodman
parent c2445c3797
commit 1c837dcad1

View file

@ -272,6 +272,16 @@ dependencies {
}
task jaxbToJava {
def xsdFilesDir = "${javaDir}/google/registry/xml/xsd"
def bindingsFile = "${javaDir}/google/registry/xjc/bindings.xjb"
def pkgInfoGenerator = "${javaDir}/google/registry/xjc/make_pkginfo.sh"
def pkgInfoTemplate = "${javaDir}/google/registry/xjc/package-info.java.in"
def outputDir = "${generatedDir}/google/registry/xjc"
inputs.dir xsdFilesDir
inputs.files bindingsFile, pkgInfoTemplate, pkgInfoGenerator
outputs.dir outputDir
doLast {
file(generatedDir).mkdirs()
@ -281,30 +291,29 @@ task jaxbToJava {
def xjcTempSourceDir = file("${temporaryDir}/xjc")
xjcTempSourceDir.mkdirs()
ant.copy(
todir: "${xjcTempSourceDir}",
overwrite: true) {
todir: "${xjcTempSourceDir}",
overwrite: true) {
fileSet(
dir: "${javaDir}/google/registry/xml/xsd",
includes: '**.xsd')
dir: xsdFilesDir,
includes: '**.xsd')
}
ant.copy(
todir: "${xjcTempSourceDir}",
overwrite: true,
file:
"${javaDir}/google/registry/xjc/bindings.xjb")
todir: "${xjcTempSourceDir}",
overwrite: true,
file: bindingsFile)
ant.taskdef(
name: 'xjc',
classname: 'com.sun.tools.xjc.XJCTask',
classpath: configurations.jaxb.asPath)
name: 'xjc',
classname: 'com.sun.tools.xjc.XJCTask',
classpath: configurations.jaxb.asPath)
ant.xjc(
destdir: "${generatedDir}",
binding: "${xjcTempSourceDir}/bindings.xjb",
removeOldOutput: 'yes', extension: 'true') {
destdir: "${generatedDir}",
binding: "${xjcTempSourceDir}/bindings.xjb",
removeOldOutput: 'yes', extension: 'true') {
project.fileTree(
dir: new File("$xjcTempSourceDir"),
include: ['**/*.xsd'])
.addToAntBuilder(ant, 'schema', FileCollection.AntType.FileSet)
dir: new File("$xjcTempSourceDir"),
include: ['**/*.xsd'])
.addToAntBuilder(ant, 'schema', FileCollection.AntType.FileSet)
// -npa: do not generate package-info.java files. They will be generated
// below.
arg(line: '-npa -quiet -extension')
@ -312,57 +321,75 @@ task jaxbToJava {
exec {
workingDir "${generatedDir}"
executable "${javaDir}/google/registry/xjc/make_pkginfo.sh"
args "${javaDir}/google/registry/xjc/package-info.java.in",
"${generatedDir}/google/registry/xjc"
executable pkgInfoGenerator
args pkgInfoTemplate, outputDir
}
}
}
task soyToJava {
// Relative paths of soy directories.
def spec11SoyDir = "google/registry/reporting/spec11/soy"
def toolsSoyDir = "google/registry/tools/soy"
def uiSoyDir = "google/registry/ui/soy"
def registrarSoyDir = "google/registry/ui/soy/registrar"
def soyRelativeDirs = [
spec11SoyDir, toolsSoyDir, uiSoyDir, registrarSoyDir,
]
soyRelativeDirs.each {
inputs.dir "${javaDir}/${it}"
outputs.dir "${generatedDir}/${it}"
}
ext.soyToJava = { javaPackage, outputDirectory, soyFiles ->
javaexec {
main = "com.google.template.soy.SoyParseInfoGenerator"
classpath configurations.soy
args "--javaPackage", "${javaPackage}",
"--outputDirectory", "${outputDirectory}",
"--javaClassNameSource", "filename",
"--allowExternalCalls", "true",
"--srcs", "${soyFiles.join(',')}"
"--outputDirectory", "${outputDirectory}",
"--javaClassNameSource", "filename",
"--allowExternalCalls", "true",
"--srcs", "${soyFiles.join(',')}"
}
}
doLast {
soyToJava('google.registry.tools.soy',
"${generatedDir}/google/registry/tools/soy",
fileTree(
dir: "${javaDir}/google/registry/tools/soy",
include: ['**/*.soy']))
"${generatedDir}/${toolsSoyDir}",
fileTree(
dir: "${javaDir}/${toolsSoyDir}",
include: ['**/*.soy']))
soyToJava('google.registry.ui.soy.registrar',
"${generatedDir}/google/registry/ui/soy/registrar",
fileTree(
dir: "${javaDir}/google/registry/ui/soy/registrar",
include: ['**/*.soy']))
"${generatedDir}/${registrarSoyDir}",
fileTree(
dir: "${javaDir}/${registrarSoyDir}",
include: ['**/*.soy']))
soyToJava('google.registry.ui.soy',
"${generatedDir}/google/registry/ui/soy",
files {
file("${javaDir}/google/registry/ui/soy").listFiles()
}.filter {
it.name.endsWith(".soy")
})
"${generatedDir}/${uiSoyDir}",
files {
file("${javaDir}/${uiSoyDir}").listFiles()
}.filter {
it.name.endsWith(".soy")
})
soyToJava('google.registry.reporting.spec11.soy',
"${generatedDir}/google/registry/reporting/spec11/soy",
fileTree(
dir: "${javaDir}/google/registry/reporting/spec11/soy",
include: ['**/*.soy']))
"${generatedDir}/${spec11SoyDir}",
fileTree(
dir: "${javaDir}/${spec11SoyDir}",
include: ['**/*.soy']))
}
}
task stylesheetsToJavascript {
def cssSourceDir = "${javaDir}/google/registry/ui/css"
def outputDir = "${project.buildDir}/resources/main/google/registry/ui/css"
inputs.dir cssSourceDir
outputs.dir outputDir
ext.cssCompile = { outputName, debug, cssFiles ->
javaexec {
main = "com.google.common.css.compiler.commandline.ClosureCommandLineCompiler"
@ -388,8 +415,6 @@ task stylesheetsToJavascript {
}
doLast {
def cssSourceDir = "${javaDir}/google/registry/ui/css"
def outputDir = "${project.buildDir}/resources/main/google/registry/ui/css"
file("${outputDir}").mkdirs()
def srcFiles = [
"${cssSourceDir}/console.css",