Class DetectDoppelgangerApisTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.arc_e_tect.gradle.doppelganger.DetectDoppelgangerApisTask
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="Report depends on source, test, contract, and OpenAPI document content and is cheap to regenerate") public abstract class DetectDoppelgangerApisTask extends org.gradle.api.DefaultTask
Gradle task that compares endpoints both declared in the configured OpenAPI documentation and implemented by scanned @RestController classes against verification evidence collected from the enabled ContractVerificationSources, and writes an AsciiDoc report of every endpoint with no such evidence - the "doppelganger APIs".

Registered automatically by DoppelgangerApiDetectorPlugin under the name detectDoppelgangerApis.

  • 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
    Task action: scans the configured controller directories and OpenAPI documentation to find endpoints both declared and implemented, scans the enabled verification sources, writes the doppelganger API report, and - when getFailOnDoppelganger() is true - fails the build if any doppelganger API was found.
    abstract org.gradle.api.file.DirectoryProperty
    Directory searched for Spring Cloud Contract DSL files when getUseSpringCloudContract() is true.
    abstract org.gradle.api.file.ConfigurableFileCollection
    Directories to search recursively for @RestController classes.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether the build should fail when doppelganger APIs are found.
    abstract org.gradle.api.file.DirectoryProperty
    Directory where OpenAPI descriptions are stored, tracked so that changes to any document reachable from getRootDocument() invalidate the task's cached result.
    abstract org.gradle.api.file.DirectoryProperty
    Directory the AsciiDoc report is written to.
    abstract org.gradle.api.provider.Property<String>
    Name of the generated AsciiDoc report file (without path).
    abstract org.gradle.api.file.RegularFileProperty
    The root OpenAPI document describing the API.
    abstract org.gradle.api.provider.Property<String>
    Version of the system under test whose @RestController classes were scanned, printed in the generated report as e.g.
    abstract org.gradle.api.file.ConfigurableFileCollection
    Directories to search recursively for test classes, scanned by the Spring RestDocs and OpenAPI request validator verification sources when enabled.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether to treat Atlassian OpenAPI request validator usage as verification evidence.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether to treat Spring RestDocs test methods as verification evidence.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether to treat Spring Cloud Contract DSL files as verification evidence.

    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

    • DetectDoppelgangerApisTask

      @Inject public DetectDoppelgangerApisTask()
      Creates the task. Instantiated by Gradle infrastructure via Inject.
  • Method Details

    • getControllerDirs

      @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getControllerDirs()
      Directories to search recursively for @RestController classes.
      Returns:
      mutable file collection of controller source directories
    • getTestDirs

      @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getTestDirs()
      Directories to search recursively for test classes, scanned by the Spring RestDocs and OpenAPI request validator verification sources when enabled.
      Returns:
      mutable file collection of test source directories
    • getRootDocument

      @InputFile @PathSensitive(RELATIVE) public abstract org.gradle.api.file.RegularFileProperty getRootDocument()
      The root OpenAPI document describing the API.
      Returns:
      mutable file property for the root OpenAPI document
    • getOpenApiDir

      @Optional @InputDirectory @PathSensitive(RELATIVE) public abstract org.gradle.api.file.DirectoryProperty getOpenApiDir()
      Directory where OpenAPI descriptions are stored, tracked so that changes to any document reachable from getRootDocument() invalidate the task's cached result.
      Returns:
      mutable directory property for the OpenAPI description directory
    • getContractsDir

      @Optional @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.DirectoryProperty getContractsDir()
      Directory searched for Spring Cloud Contract DSL files when getUseSpringCloudContract() is true.

      Validated as @InputFiles rather than @InputDirectory: most projects have no contracts directory at all, and unlike @InputDirectory, @InputFiles does not require the configured directory to actually exist.

      Returns:
      mutable directory property for the Spring Cloud Contract directory
    • getUseRestDocs

      @Input public abstract org.gradle.api.provider.Property<Boolean> getUseRestDocs()
      Whether to treat Spring RestDocs test methods as verification evidence.
      Returns:
      mutable boolean property controlling whether the Spring RestDocs source is enabled
    • getUseOpenApiRequestValidator

      @Input public abstract org.gradle.api.provider.Property<Boolean> getUseOpenApiRequestValidator()
      Whether to treat Atlassian OpenAPI request validator usage as verification evidence.
      Returns:
      mutable boolean property controlling whether the OpenAPI request validator source is enabled
    • getUseSpringCloudContract

      @Input public abstract org.gradle.api.provider.Property<Boolean> getUseSpringCloudContract()
      Whether to treat Spring Cloud Contract DSL files as verification evidence.
      Returns:
      mutable boolean property controlling whether the Spring Cloud Contract source is enabled
    • getFailOnDoppelganger

      @Input public abstract org.gradle.api.provider.Property<Boolean> getFailOnDoppelganger()
      Whether the build should fail when doppelganger APIs are found.
      Returns:
      mutable boolean property controlling whether the build fails on doppelganger APIs
    • getReportDir

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getReportDir()
      Directory the AsciiDoc report is written to.
      Returns:
      mutable directory property for the report output directory
    • getReportFileName

      @Input public abstract org.gradle.api.provider.Property<String> getReportFileName()
      Name of the generated AsciiDoc report file (without path).
      Returns:
      mutable string property for the report file name
    • getSystemUnderTestVersion

      @Input public abstract org.gradle.api.provider.Property<String> getSystemUnderTestVersion()
      Version of the system under test whose @RestController classes were scanned, printed in the generated report as e.g. System Under Test version: v1.0.0.
      Returns:
      mutable string property for the system-under-test version
    • generate

      public void generate()
      Task action: scans the configured controller directories and OpenAPI documentation to find endpoints both declared and implemented, scans the enabled verification sources, writes the doppelganger API report, and - when getFailOnDoppelganger() is true - fails the build if any doppelganger API was found.