Class FixedStateTarget
- All Implemented Interfaces:
StateProvider,Target
-
Constructor Summary
ConstructorsConstructorDescriptionFixedStateTarget(Consumer<Consumer<byte[]>> stateBytesGenerator, String name, List<? extends Target> dependencies, ConsumeOrThrow<FixedStateTarget> builder) Creates a target with a fixed state generator. -
Method Summary
Modifier and TypeMethodDescriptionvoidGiven a sink forbyte[]this method should provide bytes representing a target's value.static TargetCreates a target with no builder which is never outdated itself.Return the list of targets this one depends on when being build.getName()The name of the target, unique within the graph of targets.static TargetonDependencyChange(String name, List<? extends Target> dependencies) Similar toalias(java.lang.String, bm.machine.Target)but for multiple dependenciesstatic TargetonDependencyChange(String name, List<? extends Target> dependencies, ConsumeOrThrow<FixedStateTarget> builder) Creates a target with dependencies which runs the builder only if any of these change.voidrecreate()Recreate this target.static TargetrunAlways(String name, ConsumeOrThrow<FixedStateTarget> builder) Creates a target with no dependencies with a build which is always run.static TargetrunAlways(String name, List<? extends Target> dependencies, ConsumeOrThrow<FixedStateTarget> builder) Creates a target with dependencies with a build which is always run.toString()
-
Constructor Details
-
FixedStateTarget
public FixedStateTarget(Consumer<Consumer<byte[]>> stateBytesGenerator, String name, List<? extends Target> dependencies, ConsumeOrThrow<FixedStateTarget> builder) Creates a target with a fixed state generator. NOTE: This is public for experimental reasons only. For normal usage consider one of the factory methods.- Parameters:
stateBytesGenerator- a function to generate a few fake state bytes and fill them into the provided consumername- of the targetdependencies- on which this target dependsbuilder- to be run if the build system decides so
-
-
Method Details
-
alias
Creates a target with no builder which is never outdated itself. In effect, it will trigger building the dependency and look as if it was build itself if dependency was changed, so it is an alias for the dependency- Parameters:
name- of the targetdependency- on which it depends- Returns:
- the alias target
-
runAlways
Creates a target with no dependencies with a build which is always run.NOTE: This is done by creating a fake state each time the state is asked, so the state "now" is always different from the state "last time", meaning the builder is run. But this also has the effect that targets depending on this one will always be re-created, as the assumption is that the builder, if run, creates some new state.
- Parameters:
name- of the targetbuilder- to always run- Returns:
- the target which always runs its builder
-
runAlways
public static Target runAlways(String name, List<? extends Target> dependencies, ConsumeOrThrow<FixedStateTarget> builder) Creates a target with dependencies with a build which is always run.NOTE: see note for
runAlways(String, ConsumeOrThrow)- Parameters:
name- of the targetdependencies- on which it dependsbuilder- to always run- Returns:
- the target which always runs its builder
-
onDependencyChange
public static Target onDependencyChange(String name, List<? extends Target> dependencies, ConsumeOrThrow<FixedStateTarget> builder) Creates a target with dependencies which runs the builder only if any of these change.- Parameters:
name- of the targetdependencies- on which it dependsbuilder- to eventually run- Returns:
- the target
-
onDependencyChange
Similar toalias(java.lang.String, bm.machine.Target)but for multiple dependencies- Parameters:
name- of the targetdependencies- on which it depends- Returns:
- the target
-
getName
Description copied from interface:TargetThe name of the target, unique within the graph of targets. It is used as the key for keeping a persistent state of the target in aStateStore. Some state stores have restrictions on characters which cannot be used.Note: using a non unique name can only be detected during the build and only if both targets of the same name are traversed.
-
getDependencies
Description copied from interface:TargetReturn the list of targets this one depends on when being build. This should list all targets whose change should trigger a rebuild of this target.- Specified by:
getDependenciesin interfaceTarget- Returns:
- the dependencies of this target
-
addState
Description copied from interface:StateProviderGiven a sink forbyte[]this method should provide bytes representing a target's value. If the value changes, the bytes provided must change too. But the bytes may also change if the value was not actually changed, though this will result in unnecessary builts of a target.This should not mingle in any dependency data.
As examples consider the full byte content of a file or only its last modified time. The latter changes even if a file is overwritten by itself, but for some cases, i.e. huge files, the time stamp may be preferable.
- Specified by:
addStatein interfaceStateProvider- Parameters:
sink- into which to fill the state representing bytes
-
recreate
Description copied from interface:TargetRecreate this target.- Specified by:
recreatein interfaceTarget- Throws:
BuildProblemException- as needed
-
toString
-