Class GenerateCodeTask
- 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>
The input and output directories are declared so that Gradle can answer the question it asks about every task: does this need to run at all. Without them the answer is always yes, and a project that has not touched its SQL regenerates every build.
-
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 Java code.org.gradle.api.provider.Provider<String> abstract org.gradle.api.file.DirectoryPropertyabstract org.gradle.api.file.DirectoryPropertyabstract org.gradle.api.provider.Property<wtf.metio.yosql.models.immutables.RuntimeConfiguration> abstract org.gradle.api.file.ConfigurableFileCollectionabstract org.gradle.api.file.ConfigurableFileCollectionMethods 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, notCompatibleWithConfigurationCache
-
Constructor Details
-
GenerateCodeTask
public GenerateCodeTask()
-
-
Method Details
-
getRuntimeConfiguration
@Internal public abstract org.gradle.api.provider.Property<wtf.metio.yosql.models.immutables.RuntimeConfiguration> getRuntimeConfiguration()- Returns:
- The runtime configuration to use.
-
getConfigurationFingerprint
- Returns:
- the configuration rendered as text, which is what Gradle compares between runs.
A
RuntimeConfigurationis not serializable and cannot be fingerprinted directly; itstoStringnames every setting, so two runs whose text matches were configured identically and the second has nothing to do.Without the directories in it. They are absolute, so including them keys the cache to where the checkout sits — which is the opposite of what
RELATIVEpath sensitivity andCacheableTaskare for: a machine that builds under a different path would miss every entry the build server wrote. The directories are declared separately, and Gradle fingerprints them the way it should.
-
getSourceDirectories
@InputFiles @PathSensitive(RELATIVE) @IgnoreEmptyDirectories public abstract org.gradle.api.file.ConfigurableFileCollection getSourceDirectories()- Returns:
- the Java sources the record scanner reads to build converters. Declared as an input because they decide what is generated: editing a record adds a component, and without this the task stays up to date and the stale converter is compiled against the new record.
-
getSchemaDirectories
@InputFiles @PathSensitive(RELATIVE) @IgnoreEmptyDirectories public abstract org.gradle.api.file.ConfigurableFileCollection getSchemaDirectories()- Returns:
- the DDL the schema is read from, when it lives somewhere other than among the
statements. Empty unless
schema.sqlStatementsDirectoryis set.An input for the same reason the source directories are: the DDL decides what is generated. A column added by a migration changes a generated record's components, and without this the task stays up to date across that edit — and, being a
CacheableTask, hands out a cache entry keyed on a schema it never read.
-
getInputDirectory
@InputDirectory @PathSensitive(RELATIVE) public abstract org.gradle.api.file.DirectoryProperty getInputDirectory()- Returns:
- where the `.sql` files are read from. RELATIVE path sensitivity: moving the whole project should not invalidate the result, but moving a file within it should.
-
getOutputDirectory
@OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getOutputDirectory()- Returns:
- where the generated Java is written, which is what makes the result cacheable.
-
generateCode
public void generateCode()Generate Java code.
-