Class BuildConstantsTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.SourceTask
org.cthing.gradle.plugins.buildconstants.BuildConstantsTask
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.api.tasks.util.PatternFilterable, org.gradle.util.Configurable<org.gradle.api.Task>

public abstract class BuildConstantsTask extends org.gradle.api.tasks.SourceTask
Performs reading of the build information and generation of the build constants class.
  • Nested Class Summary

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

    org.gradle.api.Named.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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Generates the build constants class.
    abstract org.gradle.api.provider.MapProperty<String,Object>
    Provides the capability to add custom constants to the source file.
    abstract org.gradle.api.provider.Property<Long>
    Obtains the time the project was built as the number of milliseconds since the Unix Epoch.
    abstract org.gradle.api.provider.Property<String>
    Obtains the fully qualified name for the generated class (e.g.
    abstract org.gradle.api.provider.Property<Boolean>
    Indicates whether the pre-defined project and build information constants should be generated.
    abstract org.gradle.api.file.DirectoryProperty
    Obtains the location on the filesystem for the generated class.
    abstract org.gradle.api.provider.Property<Object>
    Obtains the group name of the project.
    abstract org.gradle.api.provider.Property<String>
    Obtains the name of the project.
    abstract org.gradle.api.provider.Property<Object>
    Obtains the version of the project.
    abstract org.gradle.api.provider.Property<SourceAccess>
    Obtains the access modifier for the generated constants.

    Methods inherited from class org.gradle.api.tasks.SourceTask

    exclude, exclude, exclude, exclude, getExcludes, getIncludes, getSource, include, include, include, include, setExcludes, setIncludes, setSource, setSource, source

    Methods inherited from class org.gradle.api.internal.ConventionTask

    conventionMapping, conventionMapping, getConventionMapping

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

    Methods inherited from class org.gradle.api.internal.AbstractTask

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

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Constructor Details

    • BuildConstantsTask

      public BuildConstantsTask()
  • Method Details

    • getClassname

      @Input public abstract org.gradle.api.provider.Property<String> getClassname()
      Obtains the fully qualified name for the generated class (e.g. org.cthing.myapp.PropertyConstants).
      Returns:
      Fully qualified class name.
    • getOutputDirectory

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getOutputDirectory()
      Obtains the location on the filesystem for the generated class.
      Returns:
      Output directory.
    • getSourceAccess

      @Input public abstract org.gradle.api.provider.Property<SourceAccess> getSourceAccess()
      Obtains the access modifier for the generated constants. The default is SourceAccess.PUBLIC.
      Returns:
      Access modifier for the generated constants.
    • getIncludePredefinedConstants

      @Input public abstract org.gradle.api.provider.Property<Boolean> getIncludePredefinedConstants()
      Indicates whether the pre-defined project and build information constants should be generated. The default is true.
      Returns:
      true to generate the pre-defined constants.
    • getProjectName

      @Input public abstract org.gradle.api.provider.Property<String> getProjectName()
      Obtains the name of the project. The default is obtained from Project.getName().
      Returns:
      Name of the project
    • getProjectVersion

      @Input public abstract org.gradle.api.provider.Property<Object> getProjectVersion()
      Obtains the version of the project. The default is obtained from Project.getVersion().
      Returns:
      Version of the project
    • getProjectGroup

      @Input public abstract org.gradle.api.provider.Property<Object> getProjectGroup()
      Obtains the group name of the project. The default is obtained from Project.getGroup().
      Returns:
      Group name of the project
    • getBuildTime

      @Input public abstract org.gradle.api.provider.Property<Long> getBuildTime()
      Obtains the time the project was built as the number of milliseconds since the Unix Epoch. The default is the current time.
      Returns:
      Milliseconds since the Unix Epoch.
    • getAdditionalConstants

      @Optional @Input public abstract org.gradle.api.provider.MapProperty<String,Object> getAdditionalConstants()
      Provides the capability to add custom constants to the source file. The constants will be written sorted by name (i.e. key). Integer, long and boolean values are written as their respective types. All other types are written using the value of their Object.toString(). If a value is null, the constant will not be written. The following constant names must not be used for custom constants: "PROJECT_NAME", "PROJECT_VERSION", "PROJECT_GROUP", "BUILD_TIME" and "BUILD_DATE".
      Returns:
      Map for custom constants and their values.
    • generateConstants

      public void generateConstants()
      Generates the build constants class.