Class SortFilesTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.rivancic.gradle.plugin.files.tasks.sort.SortFilesTask
All Implemented Interfaces:
java.lang.Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

public abstract class SortFilesTask
extends org.gradle.api.DefaultTask
Task is grouped into "files" group.

Root folder containing files that have to be sorted is parametrized through SortFilesTaskExtension.getDirectoryLocation(). This plugin sorts files from specific directory and copies them to build/files directory. Files are being sorted based on their extension, creation date or initial character. Default sorting type is by creation date. One can explicitly define sorting type with setting SortFilesTaskExtension.getSortType() to value:

  • date
  • extension
  • alphabeth

Files are being resolved with the Project#file() method, as this way we get correct path to the relative path. Only none hidden files are taken into consideration.

Based on sorting type new subdirectory is created in build target and file is copied to matching subdirectory. Name of the subdirectory is defined with FileDirectoryMapper instance.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Task

    org.gradle.api.Task.Namer
  • Field Summary

    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
    SortFilesTask()  
  • Method Summary

    Modifier and Type Method Description
    void apply()  
    abstract org.gradle.api.file.DirectoryProperty getDirectoryLocation()
    With correctly defined task inputs and outputs task can be skipped during the execution.
    abstract org.gradle.api.file.DirectoryProperty getOutputDir()  
    abstract org.gradle.api.provider.Property<java.lang.String> getSortType()  

    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
  • Constructor Details

    • SortFilesTask

      public SortFilesTask()
  • Method Details

    • getSortType

      @Input public abstract org.gradle.api.provider.Property<java.lang.String> getSortType()
    • getDirectoryLocation

      @InputDirectory public abstract org.gradle.api.file.DirectoryProperty getDirectoryLocation()
      With correctly defined task inputs and outputs task can be skipped during the execution. See https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:up_to_date_checks
    • getOutputDir

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getOutputDir()
    • apply

      public void apply()