Class GenerateCodeTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
wtf.metio.yosql.tooling.gradle.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>

@CacheableTask public abstract class GenerateCodeTask extends org.gradle.api.DefaultTask
Generate Java code by reading SQL code.

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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Generate Java code.
    org.gradle.api.provider.Provider<String>
     
    abstract org.gradle.api.file.DirectoryProperty
     
    abstract org.gradle.api.file.DirectoryProperty
     
    abstract org.gradle.api.provider.Property<wtf.metio.yosql.models.immutables.RuntimeConfiguration>
     
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    abstract org.gradle.api.file.ConfigurableFileCollection
     

    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, 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

    Methods inherited from class Object

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

    Methods 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

      @Input public org.gradle.api.provider.Provider<String> getConfigurationFingerprint()
      Returns:
      the configuration rendered as text, which is what Gradle compares between runs. A RuntimeConfiguration is not serializable and cannot be fingerprinted directly; its toString names 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 RELATIVE path sensitivity and CacheableTask are 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.sqlStatementsDirectory is 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.