Package com.mooltiverse.oss.nyx.gradle
Class CoreTask
- java.lang.Object
-
- org.gradle.api.internal.AbstractTask
-
- org.gradle.api.DefaultTask
-
- com.mooltiverse.oss.nyx.gradle.CoreTask
-
- All Implemented Interfaces:
Comparable<Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.TaskInternal,ExtensionAware,Task,org.gradle.util.Configurable<Task>
- Direct Known Subclasses:
ArrangeTask,CleanTask,InferTask,MakeTask,MarkTask,PublishTask
public abstract class CoreTask extends DefaultTask
The abstract superclass for all Nyx core tasks. Core tasks, as opposite toLifecycleTaskare those performing some concrete actions.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gradle.api.Task
Task.Namer
-
-
Field Summary
Fields Modifier and Type Field Description static StringGROUPThe group the tasks belong to.static StringNYX_INSTANCE_PROPERTYThe name used to store and retrieve the extra property that holds the shared backing Nyx instance that can be used by all tasks.-
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
-
-
Constructor Summary
Constructors Constructor Description CoreTask(NyxExtension extension)Standard constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NyxExtensiongetExtension()Returns the instance of the extension for the task.protected booleanhasSharedProperty(String name)Returnstrueif there is a project with the given name stored for the project.protected Nyxnyx()Returns a shared backing Nyx instance to be used by all tasks within the project.protected ObjectretrieveSharedProperty(String name)Retrieves the shared project property with the given name.Statestate()Returns the state of the shared backing Nyx instance.protected voidstoreSharedProperty(String name, Object value)Stores the given value as a shared project property with the given name.-
Methods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
-
Methods inherited from class org.gradle.api.internal.AbstractTask
appendParallelSafeAction, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getOnlyIf, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, prependParallelSafeAction, setImpliesSubProjects, setLoggerMessageRewriter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.gradle.api.Task
getConvention
-
-
-
-
Field Detail
-
NYX_INSTANCE_PROPERTY
public static final String NYX_INSTANCE_PROPERTY
The name used to store and retrieve the extra property that holds the shared backing Nyx instance that can be used by all tasks.
-
GROUP
public static final String GROUP
The group the tasks belong to.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CoreTask
public CoreTask(NyxExtension extension)
Standard constructor.- Parameters:
extension- the extension object. Cannot benull.
-
-
Method Detail
-
getExtension
@Internal protected NyxExtension getExtension()
Returns the instance of the extension for the task.- Returns:
- the extension for the task
-
hasSharedProperty
protected boolean hasSharedProperty(String name)
Returnstrueif there is a project with the given name stored for the project.- Parameters:
name- the name of the property to look up- Returns:
trueif there is a project with the given name stored for the project
-
storeSharedProperty
protected void storeSharedProperty(String name, Object value)
Stores the given value as a shared project property with the given name. The name makes the property unique within the entire project.- Parameters:
name- the name of the property to storevalue- the value of the property to store
-
retrieveSharedProperty
protected Object retrieveSharedProperty(String name)
Retrieves the shared project property with the given name. The name makes the property unique within the entire project.- Parameters:
name- the name of the property to retrieve- Returns:
- the value of the shared property with the given name, if any, or
nullif no property with such name is available
-
nyx
protected Nyx nyx() throws DataAccessException, IllegalPropertyException
Returns a shared backing Nyx instance to be used by all tasks within the project. The returned instance is already configured with the values coming from theNyxExtension. This method also stores the instance as a shared project property so that all subsequent calls can retrieve the same instance to avoid creating multiple instances and saving configuration time. On the other hand, the instance is lazily created upon the first invocation so the Nyx instance is only created when needed.- Returns:
- a shared backing Nyx instance to be used by all tasks within the project.
- Throws:
DataAccessException- in case the configuration can't be loaded for some reason.IllegalPropertyException- in case the configuration has some illegal options.
-
state
public State state() throws DataAccessException, IllegalPropertyException
Returns the state of the shared backing Nyx instance.- Returns:
- the state of the shared backing Nyx instance.
- Throws:
DataAccessException- in case the configuration can't be loaded for some reason.IllegalPropertyException- in case the configuration has some illegal options.- See Also:
nyx()
-
-