Klasse MessageFormatPackTask

Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
de.sayayi.plugin.gradle.message.MessageFormatPackTask
Alle implementierten Schnittstellen:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

@CacheableTask public abstract class MessageFormatPackTask extends org.gradle.api.DefaultTask
Gradle task for scanning messages and templates in classes and packing them into a single file which can be imported into a MessageSupport.ConfigurableMessageSupport.
Seit:
0.8.0
Siehe auch:
  • Verschachtelte Klassen - Übersicht

    Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Feldübersicht

    Von Schnittstelle geerbte Felder org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    Gradle task constructor.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    void
    action(org.gradle.api.Action<@NotNull de.sayayi.lib.message.MessageSupport.MessageAccessor> action)
    Provide the task with an action that allows for querying the scanned messages and templates.
    void
    exclude(String... regex)
    Exclude messages matching the regex.
    abstract org.gradle.api.provider.Property<@NotNull Boolean>
    Return compress message pack property.
    abstract org.gradle.api.file.DirectoryProperty
    Parameter containing the destination directory where the packed message file is stored.
    abstract org.gradle.api.provider.Property<@NotNull Object>
    Property containing the strategy to use in case a duplicate message code or template name (with different message definition) is found.
    Return a list of regular expressions which will be matched against each message code.
    Return a list of regular expressions which will be matched against each message code.
    org.gradle.api.file.RegularFile
    Returns the target message pack file location.
    abstract org.gradle.api.provider.Property<@NotNull String>
    Parameter containing the packed message file name.
    abstract org.gradle.api.file.ConfigurableFileCollection
    Returns a collection of source files to scan for message and template annotations.
    abstract org.gradle.api.provider.Property<@NotNull Boolean>
    Property containing a boolean stating whether to validate referenced templates.
    void
    include(String... regex)
    Include messages matching the regex.
    void
    Scans the configured source files for message and template annotations, validates referenced templates, executes registered actions and writes the packed message file.
    void
    sourceSet(org.gradle.api.tasks.SourceSet sourceSet)
    Add all outputs for the given sourceSet to the collection of sources.

    Von Klasse geerbte Methoden 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, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Von Klasse geerbte Methoden org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjects

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Von Schnittstelle geerbte Methoden org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Konstruktordetails

    • MessageFormatPackTask

      public MessageFormatPackTask()
      Gradle task constructor.
  • Methodendetails

    • getDestinationDir

      @Internal("tracked via packFile") public abstract org.gradle.api.file.DirectoryProperty getDestinationDir()
      Parameter containing the destination directory where the packed message file is stored.
      Gibt zurück:
      destination directory parameter, never null
    • getPackFilename

      @Internal("tracked via packFile") public abstract org.gradle.api.provider.Property<@NotNull String> getPackFilename()
      Parameter containing the packed message file name.
      Gibt zurück:
      packed message file name, never null
    • getIncludeRegexFilters

      @Input public List<String> getIncludeRegexFilters()
      Return a list of regular expressions which will be matched against each message code. If it matches, the message will be included in the packed message file. If it doesn't match the message is skipped.

      If the list is empty, all messages are included, unless they're explicitly excluded.

      Gibt zurück:
      list of regular expressions for message inclusion, never null
      Siehe auch:
    • getExcludeRegexFilters

      @Input public List<String> getExcludeRegexFilters()
      Return a list of regular expressions which will be matched against each message code. If it matches, the message will be excluded from the packed message file. If it doesn't match the message is included.
      Gibt zurück:
      list of regular expressions for message exclusion, never null
      Siehe auch:
    • getSources

      @InputFiles @IgnoreEmptyDirectories @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getSources()
      Returns a collection of source files to scan for message and template annotations.

      There's no restriction on what kind of files are in the collection. This task will only use and scan class (*.class) files.

      Gibt zurück:
      collection of source files to scan for messages and templates, never null
      Siehe auch:
    • getDuplicateMsgStrategy

      @Input public abstract org.gradle.api.provider.Property<@NotNull Object> getDuplicateMsgStrategy()
      Property containing the strategy to use in case a duplicate message code or template name (with different message definition) is found. The default strategy is IGNORE_AND_WARN.

      This property accepts various formats:

      A duplicate is either a message with an already known message code or a template with an already known template name and a different message definition. This means that if the same message or template is encountered twice, it is not considered a duplicate.

      Gibt zurück:
      duplicate message strategy property, never null
      Siehe auch:
    • getValidateReferencedTemplates

      @Input public abstract org.gradle.api.provider.Property<@NotNull Boolean> getValidateReferencedTemplates()
      Property containing a boolean stating whether to validate referenced templates. The default value resolves to true.

      If the property resolves to true the task will check whether all reference templates (including nested templates) are available and included in the packed message file.

      If the property resolves to false no checks are performed. This may lead to a situation where a message cannot be formatted if the referenced template is missing from the message support.

      Gibt zurück:
      validate referenced templates property, never null
    • getCompress

      @Input public abstract org.gradle.api.provider.Property<@NotNull Boolean> getCompress()
      Return compress message pack property. The default for this property is false.
      Gibt zurück:
      compress property, never null
    • getPackFile

      @OutputFile public org.gradle.api.file.RegularFile getPackFile()
      Returns the target message pack file location.
      Gibt zurück:
      message pack file, never null
    • include

      public void include(String... regex)
      Include messages matching the regex.
      Parameter:
      regex - regex matching message codes
      Siehe auch:
    • exclude

      public void exclude(String... regex)
      Exclude messages matching the regex.
      Parameter:
      regex - regex matching message codes
      Siehe auch:
    • sourceSet

      public void sourceSet(org.gradle.api.tasks.SourceSet sourceSet)
      Add all outputs for the given sourceSet to the collection of sources.
      Parameter:
      sourceSet - source set to include in message/template scanning
      Siehe auch:
    • action

      public void action(org.gradle.api.Action<@NotNull de.sayayi.lib.message.MessageSupport.MessageAccessor> action)
      Provide the task with an action that allows for querying the scanned messages and templates. This action is invoked just before the messages and templates are written to the packed message file.

      Here's an example of how to use this action.
      Let's say all message codes start with a prefix MSG- followed by a 4-digit number (e.g. MSG-0318). The action could then be used to output the next 10 available message codes:

         action {
             def codes = getMessageCodes()
             def unusedCodes = new ArrayList<String>()
      
             for(int n = 1; unusedCodes.size() < 10; n++)
             {
               def code = String.format("MSG-%04d", n)
      
               if (!codes.contains(code))
                 unusedCodes.add(code)
             }
      
             println 'Available message codes:'
             println String.join(" ", unusedCodes)
         }
       
      If multiple actions are provided, they are executed in the order of definition.
      Parameter:
      action - custom action, not null
      Seit:
      0.8.0
    • pack

      public void pack()
      Scans the configured source files for message and template annotations, validates referenced templates, executes registered actions and writes the packed message file.
      Löst aus:
      org.gradle.api.GradleException - if scanning, validation or writing fails