do i have to explicitly supply inputs and outputs for all my gradle tasks?

StackOverflow https://stackoverflow.com/questions/23488661

  •  16-07-2023
  •  | 
  •  

Question

I am scripting up a custom gradle build and have noticed that I'm placing inputs and outputs definitions for all of my tasks.

Is this necessary for the predefined tasks or do they 'know' about their consequences and dependencies? for example, are the inputs/outputs here necessary?:

task compileGradleWrapperDependencies(type: GroovyCompile){
    source = fileTree("buildSrc/src/main/groovy") {
        include "com/example/plugins/dsl/SomeFile.groovy"
        include "com/example/plugins/dsl/OtherFile.groovy"
    }
    destinationDir = "$buildDir/tempBuildSrcCompiled"
    classpath = ...
    ...
    inputs.files fileTree("buildSrc/src/main/groovy") {
        include "com/example/plugins/dsl/SomeFile.groovy"
        include "com/example/plugins/dsl/OtherFile.groovy"
    }
    outputs.files "$buildDir/tempBuildSrcCompiled"
}
Était-ce utile?

La solution

The task classes that ship with Gradle already define their inputs and outputs (where it makes sense). Declaring the inputs and outputs above is redundant (which you can easily verify yourself).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top