Class MavenPaths

java.lang.Object
org.eclipse.jetty.toolchain.test.MavenPaths

public final class MavenPaths extends Object
Simpler replacement for MavenTestingUtils used to find paths within the Maven ${project.basedir}
  • Field Details

    • basePath

      private static Path basePath
  • Constructor Details

    • MavenPaths

      public MavenPaths()
  • Method Details

    • projectBase

      public static Path projectBase()
      Get the equivalent of ${project.basedir} (what used to just be called ${basedir}
      Returns:
      the project basedir
    • targetDir

      public static Path targetDir()
      Get the Path reference to the /target directory for this project.

      This is roughly equivalent to the ${project.build.directory} property.

      Note: this implementation does not inspect the pom.xml for non-standard locations of the ${project.build.directory} property, nor does it actually use the ${project.build.directory}.

      This is a convenience method for MavenPaths.projectBase().resolve("target") but ensures that the directory exists before returning it.

      Returns:
      the directory path to the /target directory.
    • targetTests

      public static Path targetTests()
    • targetTestDir

      public static Path targetTestDir(org.junit.jupiter.api.extension.ExtensionContext context)
      Resolve the unique test directory based on ExtensionContext
      Parameters:
      context - the ExtensionContext to build target/tests/{name} from
      Returns:
      the unique test path for the context
    • targetTestDir

      public static Path targetTestDir(org.junit.jupiter.api.TestInfo info)
      Resolve the unique test directory based on TestInfo
      Parameters:
      info - the TestInfo to build target/tests/{name} from
      Returns:
      the unique test path for the context
    • targetTestDir

      public static Path targetTestDir(String name)
      Resolve the test directory
      Parameters:
      name - the to resolve target/tests/{name} from
      Returns:
      the test path for the context
    • targetTestDir

      public static Path targetTestDir(Class<?> testClazz, String methodName, String displayName)
      Internal test directory name creation logic.

      This creates a name under target/tests/{clazzName_condensed}/{name} where {name} is either {methodName}{displayName} or {displayName} depending on if {methodName} exists or not.

      Parameters:
      testClazz - the test class name
      methodName - the method name (usually from ExtensionContext.getTestMethod() or TestInfo.getTestMethod())
      displayName - the display name (usually from ExtensionContext.getDisplayName() or TestInfo.getDisplayName())
    • findMainResourceFile

      public static Path findMainResourceFile(String name)

      Search for an expected file in the equivalent of the src/main tree.

      Search order:

      1. src/main/resources/${name}
      2. target/classes/${name}

      If name exists anywhere in the search tree, but is not a File, this results in an AssertionError

      Parameters:
      name - the name to search for (must not start with /. use only URI path separator syntax)
      Returns:
      the Path (always a regular file)
      Throws:
      AssertionError - if name does not exist, or resulting path is not a File
    • findMainResourceDir

      public static Path findMainResourceDir(String name)

      Search for an expected directory in the equivalent of the src/main tree.

      Search order:

      1. src/main/resources/${name}
      2. target/classes/${name}

      If name exists anywhere in the search tree, but is not a Directory, this results in an AssertionError

      Parameters:
      name - the name to search for (must not start with /. use only URI path separator syntax)
      Returns:
      the Path (always a directory)
      Throws:
      AssertionError - if name does not exist, or resulting path is not a directory
    • findTestResourceFile

      public static Path findTestResourceFile(String name)

      Search for an expected file in the equivalent of the src/test tree.

      Search order:

      1. src/test/resources/${name}
      2. target/test-classes/${name}
      3. ClassLoader.getResource(${name})

      If name exists anywhere in the search tree, but is not a File, this results in an AssertionError

      Parameters:
      name - the name to search for (must not start with /. use only URI path separator syntax)
      Returns:
      the Path (always a regular file)
      Throws:
      AssertionError - if name does not exist, or resulting path is not a File
    • findTestResourceDir

      public static Path findTestResourceDir(String name)

      Search for an expected file in the equivalent of the src/main tree.

      Search order:

      1. src/main/resources/${name}
      2. target/classes/${name}
      3. ClassLoader.getResource(${name})

      If name exists anywhere in the search tree, but is not a Directory, this results in an AssertionError

      Parameters:
      name - the name to search for (must not start with /. use only URI path separator syntax)
      Returns:
      the Path (always a directory)
      Throws:
      AssertionError - if name does not exist, or resulting path is not a Directory
    • absolute

      private static Path absolute(Path path)
    • findMainResource

      private static Path findMainResource(String name)
    • findTestResource

      private static Path findTestResource(String name)
    • safename

      static String safename(String name)