We have developed several custom gradle tasks and we have a debate about whether we need/should annotate properties that are configured in a gradle build script.
Here is an example:
public abstract class OmlMergeTask extends DefaultTask {
public Collection<File> inputZipPaths;
public void setInputZipPaths(Collection<File> files) {
inputZipPaths = files;
getInputFiles().from(files);
}
public Collection<File> inputFolderPaths = null;
public void setInputFolderPaths(Collection<File> files) {
inputFolderPaths = files;
getInputFiles().from(files);
}
public Collection<File> inputCatalogPaths;
public void setInputCatalogPaths(Collection<File> files) {
inputCatalogPaths = files;
getInputFiles().from(files);
}
@Incremental
@InputFiles
public abstract ConfigurableFileCollection getInputFiles();
- With Gradle 6.5.1, we can have a mix of properties with and without Gradle annotations.
Is this practice going to be supported in future versions of Gradle?
-
It seems to me that the purpose of having defined gradle annotations is precisely to facilitate annotating every configurable property explicitly. Is this a matter of pedantic style, recommended best practice or necessity (e.g. gradle 7)?
-
If we wanted to explicitly annotate
inputZipPaths
andinputFolderPaths
, it is debatable which annotation is appropriate.
@Input seems to make sense except that there is a legitimate argument that these are used to calculate genuine inputs.
@Internal seems appropriate except that the doc says that the property isn’t taken into account for up-to-date checking. Yet in this case, the value certainly matters for up-to-date checking in that if the value were to change, we’d want the task to run even if the calculated input files were somehow to be the same. So this suggests that @Input is more appropriate.
Suggestions?
- Nicolas.