Enable caching of task outputs for custom build tasks

This commit is contained in:
Ben Liblit 2018-03-31 18:02:04 -05:00
parent e42e36c4de
commit 6869a4d5f4
5 changed files with 5 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import org.gradle.api.tasks.*
// create a Javadoc-style "package-list" file
//
@CacheableTask
class CreatePackageList extends org.gradle.api.DefaultTask {
@Input Object sourceSet

View File

@ -6,6 +6,7 @@ import org.gradle.api.tasks.*
// download and use checksum to verify that we got what we expected
//
@CacheableTask
class VerifiedDownload extends org.gradle.api.DefaultTask {
// URL of resource to download

View File

@ -33,6 +33,7 @@ task generateJniHeaders(type: Exec, dependsOn: [testClasses, ':com.ibm.wala.cast
}
inputs.files files(qualifiedClasses.collect { "$buildDir/${it.replace('.', '/')}.class" })
outputs.files files(qualifiedClasses.collect { "$headerDir/${it.replace('.', '_')}.h" })
outputs.cacheIf { true }
// javah command to generate headers
def sourceSets = [sourceSets.test, project(':com.ibm.wala.cast').sourceSets.main]

View File

@ -101,6 +101,7 @@ task generateHelloHashJar(type: JavaExec, dependsOn: unpackOcamlJava) {
inputs.file 'ocaml/hello_hash.ml'
outputs.file 'hello_hash.jar'
args inputs.files.singleFile, '-o', outputs.files.singleFile
outputs.cacheIf { true }
def ocamlJavaHome = new File(files(unpackOcamlJava).singleFile, downloadOcamlJava.basename)
classpath new File(ocamlJavaHome, 'lib/ocamljava.jar')

View File

@ -53,6 +53,7 @@ task unpackAndroidSdk(type: Sync, dependsOn: downloadAndroidSdk) {
into temporaryDir
}
@CacheableTask
class InstallAndroidSdkComponent extends DefaultTask {
@Input def component
@Input def version