Class TestBuildConfigurator
java.lang.Object
com.vaadin.copilot.testrecordergenerator.TestBuildConfigurator
- Direct Known Subclasses:
BrowserlessBuildConfigurator,TestBenchBuildConfigurator
Base class for adding the test dependencies of recorded tests to a Maven or
Gradle (Groovy or Kotlin DSL) build.
Dependencies are added in test scope without a version, which requires that the version is managed by a BOM (the Vaadin BOM manages the Vaadin test artifacts, Spring Boot manages its own test dependencies). When no BOM can be found the dependency is not added and a warning is returned instead of guessing a version. All operations are idempotent.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhich BOM manages the version of a dependency.static final recordA test scoped dependency without version, the version comes from a BOM. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDependencies(Path moduleRoot, List<TestBuildConfigurator.TestDependency> dependencies, List<String> added, List<String> warnings) Adds the given test dependencies to the build file in the module root.protected booleanconfigureGradleBuild(GradleFileRewriter rewriter, String content) Called when a Gradle build file is configured, to make changes other than adding dependencies.protected booleanhasDependency(Path moduleRoot, String groupId, String artifactId) Checks whether the build file in the module root declares the given dependency.
-
Constructor Details
-
TestBuildConfigurator
protected TestBuildConfigurator()
-
-
Method Details
-
addDependencies
protected void addDependencies(Path moduleRoot, List<TestBuildConfigurator.TestDependency> dependencies, List<String> added, List<String> warnings) throws IOException Adds the given test dependencies to the build file in the module root.- Parameters:
moduleRoot- the module root folderdependencies- the dependencies to addadded- receives the dependencies that were added, asgroupId:artifactIdwarnings- receives the messages to show to the user- Throws:
IOException- if the build file cannot be read or written
-
hasDependency
protected boolean hasDependency(Path moduleRoot, String groupId, String artifactId) throws IOException Checks whether the build file in the module root declares the given dependency.- Parameters:
moduleRoot- the module root foldergroupId- the group idartifactId- the artifact id- Returns:
- true if a
pom.xml,build.gradleorbuild.gradle.ktsdeclares the dependency, false otherwise - Throws:
IOException- if the build file cannot be read
-
configureGradleBuild
Called when a Gradle build file is configured, to make changes other than adding dependencies. UseGradleFileRewriter.isKotlinDsl()to pick the syntax of added code. Does nothing by default.- Parameters:
rewriter- the rewriter for the build filecontent- the content of the build file before any changes, without comments- Returns:
- true if the build file was changed
-