Class TestBuildConfigurator

java.lang.Object
com.vaadin.copilot.testrecordergenerator.TestBuildConfigurator
Direct Known Subclasses:
BrowserlessBuildConfigurator, TestBenchBuildConfigurator

public abstract class TestBuildConfigurator extends Object
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.

  • 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 folder
      dependencies - the dependencies to add
      added - receives the dependencies that were added, as groupId:artifactId
      warnings - 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 folder
      groupId - the group id
      artifactId - the artifact id
      Returns:
      true if a pom.xml, build.gradle or build.gradle.kts declares the dependency, false otherwise
      Throws:
      IOException - if the build file cannot be read
    • configureGradleBuild

      protected boolean configureGradleBuild(GradleFileRewriter rewriter, String content)
      Called when a Gradle build file is configured, to make changes other than adding dependencies. Use GradleFileRewriter.isKotlinDsl() to pick the syntax of added code. Does nothing by default.
      Parameters:
      rewriter - the rewriter for the build file
      content - the content of the build file before any changes, without comments
      Returns:
      true if the build file was changed