Class Clean

  • All Implemented Interfaces:
    IconProvider

    public class Clean
    extends TaskAction
    Task action that deletes build products. This task action can be used with custom task types. It is applicable to any task folder that defines the key with the name KEY_CLEAN_EXTENSIONS ("clean-ext"). The value of this key should be set to a comma-separated list of the file extensions of all file types that should be deleted by the action. For example, the value "class,jar" would delete all compiled Java class files and JAR archives.
    Since:
    2.1
    Author:
    Chris Jennings
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String KEY_CLEAN_EXTENSIONS
      Set the key with this name on a task's settings to a comma-separated list of file extensions and the clean command will automatically apply to that task and delete the files with those extensions.
    • Constructor Summary

      Constructors 
      Constructor Description
      Clean()  
    • Field Detail

      • KEY_CLEAN_EXTENSIONS

        public static final java.lang.String KEY_CLEAN_EXTENSIONS
        Set the key with this name on a task's settings to a comma-separated list of file extensions and the clean command will automatically apply to that task and delete the files with those extensions.
        See Also:
        Task.getSettings(), Constant Field Values
    • Constructor Detail

      • Clean

        public Clean()
    • Method Detail

      • getLabel

        public java.lang.String getLabel()
        Description copied from class: TaskAction
        Returns the human-readable name of this action.
        Specified by:
        getLabel in class TaskAction
        Returns:
        the name used to create menu items for this action, localized if possible
      • getDescription

        public java.lang.String getDescription()
        Description copied from class: TaskAction
        Returns a longer description of the action, suitable for use as a tool tip.
        Overrides:
        getDescription in class TaskAction
        Returns:
        a long description of the action, or null
      • perform

        public boolean perform​(Project project,
                               Task task,
                               Member member)
        Description copied from class: TaskAction
        Perform this action on a member of a project, a project or a task. If the project itself is the target, task and member will be null. If a task is the target, then member will be null. If an error occurs while executing the task, then it is the action's responsibility to inform the user. This method can return false to indicate that if the action is being applied to multiple members, it should stop immediately rather than continue to the next member.
        Specified by:
        perform in class TaskAction
        Parameters:
        project - the project that is being acted upon
        task - the task within the project that is being acted upon; null if acting on a project
        member - the specific member within the task to act upon; null if this is a project or task
      • appliesTo

        public boolean appliesTo​(Project project,
                                 Task task,
                                 Member member)
        Description copied from class: TaskAction
        Returns true if this action can be performed on the specified member of a project, project or a task. If the project itself is the target, task and member will be null. If a task is the target, then member will be null. If an error occurs while executing the task, then it is the action's responsibility to inform the user. This method can return false to indicate that if the action is being applied to multiple members, it should stop immediately rather than continue to the next member.
        Specified by:
        appliesTo in class TaskAction
        Parameters:
        project - the project that is being acted upon
        task - the task within the project that is being acted upon; null if acting on a project
        member - the specific member within the task to act upon; null if this is a project or task
      • willDelete

        protected boolean willDelete​(Member m,
                                     java.lang.String[] extensions)
        Returns true if the clean command should delete a particular file or folder. The base class implementation returns true when the member is not a folder and its extension matches one of those that is passed in. Subclasses can override this to create customized clean actions for a specific task. (If the new action uses KEY_CLEAN_EXTENSIONS, then you should extend the original command as a SpecializedAction to avoid having both clean commands match a task.)
        Parameters:
        m - the candidate for deletion
        extensions - an array of file extensions that may be used to assist in decision-making
        Returns:
        true if m should be deleted by a clean operation