Package app.spellscroll.task
Class GenerateBuildConfigTask
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
app.spellscroll.task.GenerateBuildConfigTask
- All Implemented Interfaces:
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 GenerateBuildConfigTask
extends org.gradle.api.DefaultTask
Gradle task that generates a Java constants class containing plugin metadata.
The generated class is named {PluginName}Constants (e.g. MyPluginConstants)
and is placed in the package derived from project.group. It exposes three
public static final String fields: PLUGIN_ID, PLUGIN_VERSION,
and PLUGIN_NAME.
Example output for group = 'com.example' and pluginName = 'My Plugin':
package com.example;
public final class MyPluginConstants {
public static final String PLUGIN_ID = "com.example.my-plugin";
public static final String PLUGIN_VERSION = "1.1.0";
public static final String PLUGIN_NAME = "My Plugin";
private MyPluginConstants() {}
}
This task is annotated CacheableTask and only reruns when the build file or
any of its inputs change. It is wired automatically into compileJava by
SpellscrollGradlePlugin.
-
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 TypeMethodDescriptionvoidgenerate()Generates the{PluginName}Constants.javasource file.abstract org.gradle.api.file.RegularFilePropertyThe project'sbuild.gradlefile, declared as an input so the task reruns whenever the build script changes.abstract org.gradle.api.file.DirectoryPropertyThe directory into which the generated.javafile is written.abstract org.gradle.api.provider.Property<String>The plugin identifier (registered at Spellscroll.app under "Developer Tools") This identifier is always an all-lowercase alphanumeric only string.abstract org.gradle.api.provider.Property<String>Human-readable plugin name (e.g.abstract org.gradle.api.provider.Property<String>Plugin version string (e.g.abstract org.gradle.api.provider.Property<String>Gradleproject.groupvalue used to derive the package name of the generated class.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, usesServiceMethods inherited from class 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, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, notCompatibleWithConfigurationCache
-
Constructor Details
-
GenerateBuildConfigTask
public GenerateBuildConfigTask()
-
-
Method Details
-
getPluginId
The plugin identifier (registered at Spellscroll.app under "Developer Tools") This identifier is always an all-lowercase alphanumeric only string. Embedded asPLUGIN_IDin the generated class.- Returns:
- the plugin ID input property
-
getPluginName
Human-readable plugin name (e.g.My Plugin). Used to derive the generated class name and embedded asPLUGIN_NAME.- Returns:
- the plugin name input property
-
getPluginVersion
Plugin version string (e.g.1.0.0). Embedded asPLUGIN_VERSIONin the generated class.- Returns:
- the plugin version input property
-
getProjectGroup
Gradleproject.groupvalue used to derive the package name of the generated class. An empty orunspecifiedgroup produces a default-package class.- Returns:
- the project group input property
-
getBuildFile
@InputFile @PathSensitive(NONE) public abstract org.gradle.api.file.RegularFileProperty getBuildFile()The project'sbuild.gradlefile, declared as an input so the task reruns whenever the build script changes.- Returns:
- the build file input property
-
getOutputDir
@OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getOutputDir()The directory into which the generated.javafile is written. Defaults tobuild/generated/sources/spellscroll/main/java.- Returns:
- the output directory property
-
generate
Generates the{PluginName}Constants.javasource file.Creates the package directory structure as needed, then writes the class with
PLUGIN_ID,PLUGIN_VERSION, andPLUGIN_NAMEfields.- Throws:
IOException- if the output file cannot be written
-