Class VerifyApiSpecTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.arc_e_tect.gradle.apionly.subscriber.VerifyApiSpecTask
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>

@DisableCachingByDefault(because="Verification is the point. A cached \'it matched last time\' is precisely the answer this task must never give: the file on disk may have been edited since, and skipping the check because the inputs look familiar would hide exactly the drift it exists to find.") public abstract class VerifyApiSpecTask extends org.gradle.api.DefaultTask
Fails when a fetched contract no longer matches what was locked. This is the verbatim guarantee, and the reason the lockfile is committed. It catches both halves of the problem: a document edited by hand after it was fetched, and a published version that changed underneath a tag that was supposed to be immutable.
  • 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
    Creates the task.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.file.DirectoryProperty
    Where the fetched documents are, and are checked.
    abstract org.gradle.api.file.RegularFileProperty
    The lockfile the fetched documents are checked against.
    abstract org.gradle.api.provider.Property<String>
    The contract being checked.
    void
    Fails when a fetched contract no longer matches what was locked.

    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 java.lang.Object

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

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Constructor Details

    • VerifyApiSpecTask

      public VerifyApiSpecTask()
      Creates the task. Gradle instantiates this when a subscription is declared.
  • Method Details

    • getTarget

      @Input public abstract org.gradle.api.provider.Property<String> getTarget()
      The contract being checked.
      Returns:
      the target name, used to find its entry in the lockfile
    • getInto

      @Internal public abstract org.gradle.api.file.DirectoryProperty getInto()
      Where the fetched documents are, and are checked.

      Deliberately @Internal rather than @InputDirectory. This task has no outputs and is not cacheable, so it runs every time regardless and there is no up-to-date check for a declared input to inform. Declaring it would only add Gradle's own existence check, which fires before this task runs and reports a missing property where the reader needs to be told that nothing has been fetched yet.

      Returns:
      the directory holding the fetched documents
    • getLockfile

      @Internal public abstract org.gradle.api.file.RegularFileProperty getLockfile()
      The lockfile the fetched documents are checked against.

      @Internal for the same reason as getInto(). A missing lockfile is an ordinary first-run state, not a misconfiguration: a project that applies the plugin and runs check before it has ever fetched anything has no lockfile yet.

      Returns:
      the lockfile location
    • verify

      public void verify()
      Fails when a fetched contract no longer matches what was locked.

      Every problem found is reported at once rather than the first, since a contract that has drifted has usually drifted in more than one file.

      Throws:
      org.gradle.api.GradleException - if nothing has been fetched, if there is no lockfile or no entry for this target, or if any document is missing or no longer hashes to what was locked