Class DoppelgangerApiDetectorExtension
java.lang.Object
com.arc_e_tect.gradle.doppelganger.DoppelgangerApiDetectorExtension
DSL extension for the Doppelganger API Detector Gradle plugin.
doppelgangerApiDetector {
controllerDirs.from('src/main/java') // default
testDirs.from('src/test/java') // default
rootDocument = file('src/main/resources/openapi/openapi.yaml') // required
// openApiDir = rootDocument.get().asFile.parentFile // default
// contractsDir = file('src/test/resources/contracts') // default
useRestDocs = true // default
useOpenApiRequestValidator = true // default
useSpringCloudContract = true // default
failOnDoppelganger = false // default
reportDir = layout.buildDirectory.dir('reports/doppelganger-api-detector') // default
reportFileName = 'doppelganger-apis.adoc' // default
// systemUnderTestVersion = 'v1.0.0' // optional; default: project.version
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault relative path of the directory searched for Spring Cloud Contract DSL files.static final StringDefault relative path of the directory searched for@RestControllerclasses.static final StringDefault name of the generated AsciiDoc report file.static final StringDefault relative path of the directory searched for test classes.static final StringExtension DSL block name, i.e. -
Constructor Summary
ConstructorsConstructorDescriptionFor use by the Gradle-generated concrete subclass. -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.file.DirectoryPropertyDirectory searched for Spring Cloud Contract DSL files (*.groovyand*.yml), scanned recursively whengetUseSpringCloudContract()istrue.abstract org.gradle.api.file.ConfigurableFileCollectionDirectories to search recursively for@RestControllerclasses.abstract org.gradle.api.provider.Property<Boolean> Whether the build should fail when doppelganger APIs are found.abstract org.gradle.api.file.DirectoryPropertyDirectory where OpenAPI descriptions are stored.abstract org.gradle.api.file.DirectoryPropertyDirectory 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.RegularFilePropertyThe root OpenAPI document describing the API.abstract org.gradle.api.provider.Property<String> Version of the system under test whose@RestControllerclasses are scanned, printed in the generated report as e.g.abstract org.gradle.api.file.ConfigurableFileCollectionDirectories 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 (amockMvc.perform(...)call paired with.andDo(document(...))) as verification evidence.abstract org.gradle.api.provider.Property<Boolean> Whether to treat Spring Cloud Contract DSL files undergetContractsDir()as verification evidence.
-
Field Details
-
NAME
Extension DSL block name, i.e. the name used to register the extension with the project.- See Also:
-
DEFAULT_CONTROLLER_DIR
Default relative path of the directory searched for@RestControllerclasses.- See Also:
-
DEFAULT_TEST_DIR
Default relative path of the directory searched for test classes.- See Also:
-
DEFAULT_CONTRACTS_DIR
Default relative path of the directory searched for Spring Cloud Contract DSL files.- See Also:
-
DEFAULT_REPORT_FILE_NAME
Default name of the generated AsciiDoc report file.- See Also:
-
-
Constructor Details
-
DoppelgangerApiDetectorExtension
public DoppelgangerApiDetectorExtension()For use by the Gradle-generated concrete subclass.
-
-
Method Details
-
getControllerDirs
public abstract org.gradle.api.file.ConfigurableFileCollection getControllerDirs()Directories to search recursively for@RestControllerclasses. One or more directories may be configured. Defaults to "src/main/java".- Returns:
- mutable file collection of controller source directories
-
getTestDirs
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. One or more directories may be configured. Defaults to "src/test/java".- Returns:
- mutable file collection of test source directories
-
getRootDocument
public abstract org.gradle.api.file.RegularFileProperty getRootDocument()The root OpenAPI document describing the API. Required: every other OpenAPI document is expected to be reachable from this one via$reflinks relative to it.- Returns:
- mutable file property for the root OpenAPI document
-
getOpenApiDir
public abstract org.gradle.api.file.DirectoryProperty getOpenApiDir()Directory where OpenAPI descriptions are stored. Used only to determine which files the task should track as inputs for up-to-date checks; every document actually consulted is discovered by following the$reflinks reachable fromgetRootDocument(). Defaults to the root document's own parent directory.- Returns:
- mutable directory property for the OpenAPI description directory
-
getContractsDir
public abstract org.gradle.api.file.DirectoryProperty getContractsDir()Directory searched for Spring Cloud Contract DSL files (*.groovyand*.yml), scanned recursively whengetUseSpringCloudContract()istrue. Defaults to "src/test/resources/contracts".- Returns:
- mutable directory property for the Spring Cloud Contract directory
-
getUseRestDocs
Whether to treat Spring RestDocs test methods (amockMvc.perform(...)call paired with.andDo(document(...))) as verification evidence. Defaults totrue.- Returns:
- mutable boolean property controlling whether the Spring RestDocs source is enabled
-
getUseOpenApiRequestValidator
Whether to treat Atlassian OpenAPI request validator usage as verification evidence. Defaults totrue.- Returns:
- mutable boolean property controlling whether the OpenAPI request validator source is enabled
-
getUseSpringCloudContract
Whether to treat Spring Cloud Contract DSL files undergetContractsDir()as verification evidence. Defaults totrue.- Returns:
- mutable boolean property controlling whether the Spring Cloud Contract source is enabled
-
getFailOnDoppelganger
Whether the build should fail when doppelganger APIs are found. The report is written either way. Defaults tofalse.- Returns:
- mutable boolean property controlling whether the build fails on doppelganger APIs
-
getReportDir
public abstract org.gradle.api.file.DirectoryProperty getReportDir()Directory the AsciiDoc report is written to. Defaults tobuild/reports/doppelganger-api-detector.- Returns:
- mutable directory property for the report output directory
-
getReportFileName
Name of the generated AsciiDoc report file (without path). Defaults to "doppelganger-apis.adoc".- Returns:
- mutable string property for the report file name
-
getSystemUnderTestVersion
Version of the system under test whose@RestControllerclasses are scanned, printed in the generated report as e.g.System Under Test version: v1.0.0. Defaults to the project's ownversion(as set in the build file or a properties file); set this property to override that default, e.g. when the controllers scanned belong to a different artifact than the one being built.- Returns:
- mutable string property for the system-under-test version
-