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
,Configurable<Task>
- Direct Known Subclasses:
CleanTask
,InferTask
,MakeTask
,MarkTask
,PublishTask
public abstract class CoreTask extends DefaultTask
The abstract superclass for all Nyx core tasks. Core tasks, as opposite toLifecycleTask
are 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 String
GROUP
The group the tasks belong to.static 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.static String
NYX_STATE_PROPERTY
The name used to store and retrieve the extra property that holds the state of the backing Nyx instance that can be used by all tasks and also user scripts.-
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 NyxExtension
getExtension()
Returns the instance of the extension for the task.protected boolean
hasSharedProperty(String name)
Returnstrue
if there is a project with the given name stored for the project.protected Nyx
nyx()
Returns a shared backing Nyx instance to be used by all tasks within the project.protected Object
retrieveSharedProperty(String name)
Retrieves the shared project property with the given name.State
state()
Returns the state of the shared backing Nyx instance.protected void
storeSharedProperty(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, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects
-
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
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
-
-
-
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.
-
NYX_STATE_PROPERTY
public static final String NYX_STATE_PROPERTY
The name used to store and retrieve the extra property that holds the state of the backing Nyx instance that can be used by all tasks and also user scripts.
-
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)
Returnstrue
if there is a project with the given name stored for the project.- Parameters:
name
- the name of the property to look up- Returns:
true
if 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
null
if 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. Moreover, the backing instance state object reference is stores as an extra property for use by user scripts. 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()
-
-