public static final class GradleTask.Builder
extends java.lang.Object
GradleTask
.
NOTE: unlike most classes following the Builder
pattern,
this one provides applyNowTo(Project)
method instead of
build(..)
. This is done to add some additional semantics to
such an irreversible action like this.
Modifier and Type | Method and Description |
---|---|
GradleTask.Builder |
allowNoDependencies()
States that the task dependencies will be added to the task later.
|
GradleTask |
applyNowTo(org.gradle.api.Project project)
Builds an instance of
GradleTask and inserts it to the project
build lifecycle according to the "before" and "after" tasks specified in the builder. |
GradleTask.Builder |
insertAfterAllTasks(TaskName target)
Inserts tasks which will precede the new one.
|
GradleTask.Builder |
insertAfterTask(TaskName target)
Specify a task which will precede the new one.
|
GradleTask.Builder |
insertBeforeTask(TaskName target)
Specify a task which will follow the new one.
|
GradleTask.Builder |
withInputFiles(org.gradle.api.file.FileCollection inputs)
Adds the files and/or directories to the input file set for the task being built.
|
GradleTask.Builder |
withInputProperty(java.lang.String propertyName,
@Nullable java.io.Serializable value)
Adds a task input property.
|
GradleTask.Builder |
withOutputFiles(org.gradle.api.file.FileCollection outputs)
Adds the files and/or directories to the output file set for the task being built.
|
public GradleTask.Builder insertBeforeTask(TaskName target)
Once built, the new instance of GradleTask
will be inserted
before the anchor.
NOTE: invocation of either this method or insertAfterTask(io.spine.tools.gradle.TaskName)
is mandatory,
as the newly created instance of GradleTask
must be put to
a certain place in the Gradle build lifecycle.
target
- the name of the task, serving as "before" anchorBuilder
public GradleTask.Builder insertAfterTask(TaskName target)
Once built, the new instance of GradleTask
will be inserted
after the anchor.
NOTE: invocation of either this method or insertBeforeTask(io.spine.tools.gradle.TaskName)
is mandatory,
as the newly created instance of GradleTask
must be put
to a certain place in the Gradle build lifecycle.
target
- the name of the task, serving as "after" anchorBuilder
public GradleTask.Builder insertAfterAllTasks(TaskName target)
Unlike insertAfterTask()
, this method will depend
the new task on every task with such name in the project (i.e. the tasks of
the root project and all the subprojects).
If a certain project does not have a task with the specified name, no action is performed for that project.
This method does not guarantee that the task will be included into a standard Gradle build.
Invocation of this method may substitute the invocation of
insertAfterTask(io.spine.tools.gradle.TaskName)
or insertBeforeTask(io.spine.tools.gradle.TaskName)
if it's guaranteed that at least
one task with such name exists. Though the fallback is never handled and there is
no guarantee that the task will get into the Gradle task graph.
target
- the name of the tasks, serving as "after" anchorBuilder
public GradleTask.Builder allowNoDependencies()
If this method is not called, the dependencies must be specified via this builder.
public GradleTask.Builder withInputFiles(org.gradle.api.file.FileCollection inputs)
If none of the specified file system elements are present before the task
execution, the task will be marked as NO-SOURCE
and skipped.
Multiple invocations appends the new files to the existing ones.
inputs
- the task input filesBuilder
public GradleTask.Builder withInputProperty(java.lang.String propertyName, @Nullable java.io.Serializable value)
An input property is treated in a similar way as an input file.
Multiple invocations of this method append new properties. If there already is a property with is such a name, the value is overridden.
propertyName
- the name of the propertyvalue
- the value of the propertyBuilder
public GradleTask.Builder withOutputFiles(org.gradle.api.file.FileCollection outputs)
If all the files listed as output do not change since the previous run of the task,
the task will be marked as UP-TO-DATE
and skipped.
Note that a task is not skipped if its inputs
are changes.
outputs
- the task output filesBuilder
@CanIgnoreReturnValue public GradleTask applyNowTo(org.gradle.api.Project project)
GradleTask
and inserts it to the project
build lifecycle according to the "before" and "after" tasks specified in the builder.project
- the target Gradle project