Class FetchApiSpecTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.arc_e_tect.gradle.apionly.subscriber.FetchApiSpecTask
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="Records its entry in apionly.lock, a file every subscription in the project shares; restoring one fetch from the build cache would overwrite the others\' entries") public abstract class FetchApiSpecTask extends org.gradle.api.DefaultTask
Unpacks a subscribed contract into the build, and records what it unpacked. Declared inputs and outputs, so it is up-to-date-checked, and so the build depends on it rather than relying on somebody remembering to run a script first. The lockfile is shared by every subscription in a project, so it is not an output of any one fetch: if it were, each fetch recording its own entry would change the others' outputs, and they would never be up to date. A fetch is up to date only while the lockfile still records what it fetched. For the same reason the task is not cacheable: restoring one fetch from the build cache would restore a whole lockfile over the other subscriptions' entries.
  • 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
    void
    Unpacks the archive, verifies it against its own manifest, and records the result in the lockfile.
    abstract org.gradle.api.file.ConfigurableFileCollection
    The resolved archive.
    protected abstract org.gradle.api.file.ArchiveOperations
    Gradle's archive operations, used to unpack the fetched .tgz.
    abstract org.gradle.api.provider.Property<String>
    Which channel the archive came from.
    protected abstract org.gradle.api.file.FileSystemOperations
    Gradle's filesystem operations, used to clear and repopulate the destination.
    abstract org.gradle.api.file.DirectoryProperty
    Where the documents are unpacked to.
    abstract org.gradle.api.file.RegularFileProperty
    The lockfile this task records what it unpacked in.
    abstract org.gradle.api.provider.Property<String>
    The contract being fetched.
    abstract org.gradle.api.provider.Property<String>
    The version being fetched.

    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

    • FetchApiSpecTask

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

    • getArchives

      @Inject protected abstract org.gradle.api.file.ArchiveOperations getArchives()
      Gradle's archive operations, used to unpack the fetched .tgz.
      Returns:
      the injected archive operations
    • getFiles

      @Inject protected abstract org.gradle.api.file.FileSystemOperations getFiles()
      Gradle's filesystem operations, used to clear and repopulate the destination.
      Returns:
      the injected filesystem operations
    • getArchive

      @InputFiles @PathSensitive(NAME_ONLY) public abstract org.gradle.api.file.ConfigurableFileCollection getArchive()
      The resolved archive.

      For the maven channel this is a resolved dependency, so Gradle has already downloaded, cached and verified the artifact itself before this task runs. For the file channel it is the path the archive belongs at, which need not exist before this task runs: a task earlier in the same build may be the one that publishes it.

      Returns:
      the archive to unpack, as a single-file collection
    • getTarget

      @Input public abstract org.gradle.api.provider.Property<String> getTarget()
      The contract being fetched.

      Used to key the lockfile entry and to name the target in any failure.

      Returns:
      the target name
    • getVersion

      @Input public abstract org.gradle.api.provider.Property<String> getVersion()
      The version being fetched.

      Checked against the version the archive's own manifest declares, so an archive published under the wrong coordinates is refused rather than unpacked.

      Returns:
      the version to record in the lockfile
    • getChannel

      @Input public abstract org.gradle.api.provider.Property<String> getChannel()
      Which channel the archive came from.

      Recorded in the lockfile so that a reader can tell where a contract was resolved from without re-running the build.

      Returns:
      the channel name, "maven" or "file"
    • getInto

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getInto()
      Where the documents are unpacked to.

      Declared as an output, so Gradle treats a modified document as making this task out of date and refetches it.

      Returns:
      the destination directory
    • getLockfile

      @Internal public abstract org.gradle.api.file.RegularFileProperty getLockfile()
      The lockfile this task records what it unpacked in.

      @Internal: every subscription in the project records its entry in this one file, so it is no single fetch's output. Whether this fetch is up to date depends on lockRecordsThisFetch() instead.

      Returns:
      the lockfile location
    • fetch

      public void fetch()
      Unpacks the archive, verifies it against its own manifest, and records the result in the lockfile.

      Four things are refused rather than unpacked: an archive that is not there, an archive whose manifest names a different version, an archive missing a document its manifest declares, and an archive whose contents do not hash to what its manifest says. A fifth is refused at the lockfile: a version already locked, coming back with different bytes — published to the file channel again, or, from a repository, a released version rebuilt or a tag moved.

      Throws:
      org.gradle.api.GradleException - if any of those checks fail