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 -
Method Summary
Modifier and TypeMethodDescriptionvoidGenerates the build constants class.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.DirectoryPropertyObtains 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, sourceMethods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMappingMethods 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, usesServiceMethods 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, setImpliesSubProjectsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, notCompatibleWithConfigurationCache
-
Constructor Details
-
BuildConstantsTask
public BuildConstantsTask()
-
-
Method Details
-
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
Obtains the access modifier for the generated constants. The default isSourceAccess.PUBLIC.- Returns:
- Access modifier for the generated constants.
-
getIncludePredefinedConstants
Indicates whether the pre-defined project and build information constants should be generated. The default istrue.- Returns:
trueto generate the pre-defined constants.
-
getProjectName
Obtains the name of the project. The default is obtained fromProject.getName().- Returns:
- Name of the project
-
getProjectVersion
Obtains the version of the project. The default is obtained fromProject.getVersion().- Returns:
- Version of the project
-
getProjectGroup
Obtains the group name of the project. The default is obtained fromProject.getGroup().- Returns:
- Group name of the project
-
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 theirObject.toString(). If a value isnull, 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.
-