Class CoreTask

    • Constructor Detail

      • CoreTask

        public CoreTask()
        Default constructor.
    • Method Detail

      • configure

        protected static void configure​(com.mooltiverse.oss.nyx.gradle.AbstractTask task)
        Configures the task by defining properties common to all core tasks. Also invokes the same method from superclass method. Child classes should invoke this method during the configuration phase.
        Parameters:
        task - the task to configure
        See Also:
        AbstractTask.configure(AbstractTask)
      • retrieveExtension

        protected static NyxExtension retrieveExtension​(Project project)
        Returns the instance of the extension for the given project.
        Parameters:
        project - the project to return the extension for
        Returns:
        the extension for the given project
      • retrieveExtension

        protected NyxExtension retrieveExtension()
        Returns the instance of the extension for the task.
        Returns:
        the extension for the task
      • hasSharedProperty

        protected boolean hasSharedProperty​(String name)
        Returns true 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 store
        value - 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 the NyxExtension. 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.
      • findTask

        protected static TaskProvider<Task> findTask​(Project project,
                                                     String name)
        Returns the provider for the task with the given name or null if no task has been registered or created with such name in the given project. The returned provider can also be used to set a property and is used for lazy instantiation so the task represented by the provider will only be created when it's actually needed. This is the same as TaskCollection.named(String) but in case there is no such task returns null instead of throwing an exception. For this reason this method does not trigger the creation of the task if it was only registered, according to Configuration Avoidance.
        Parameters:
        project - the project to look up the task into
        name - the name of the task to look up
        Returns:
        the provider for the given task or null if there is no such task
      • define

        protected static <T extends TaskTaskProvider<T> define​(Project project,
                                                                 String name,
                                                                 Class<T> type,
                                                                 Action<? super T> configurationAction)
        Registers the task into the given project. Once the task is registered it's not yet instantiated but, instead, a provider object is returned. The provider can also be used to set properties. What's important is that the provider does not instantiate the task until it's actually needed and this prevents unnecessary load. The task is defined lazily so it will be actually created by Gradle only when needed, according to the Configuration Avoidance. For this reason TaskContainer.register(String, Class, Action) is used instead of TaskContainer.create(String, Class, Action) internally.
        Type Parameters:
        T - the task class
        Parameters:
        project - the project to define the task for
        name - the name to register the task with
        type - the task class
        configurationAction - the optional action used to configure the task upon creation. It may be null
        Returns:
        the task provider used for the deferred task instantiation