Class Workspaces

java.lang.Object
io.github.ascopes.jct.utils.UtilityClass
io.github.ascopes.jct.workspaces.Workspaces

public final class Workspaces extends io.github.ascopes.jct.utils.UtilityClass
Helpers to create new workspaces.
Since:
0.0.1
Author:
Ashley Scopes
  • Method Details

    • newWorkspace

      public static Workspace newWorkspace()
      Create a new default workspace instance using the default path strategy.

      This workspace must be closed after use. Ideally, you should use a try-with-resources to achieve this. Failing to do this will lead to resources being leaked and tests not being cleared up correctly.

      The workspace can be passed to JctCompiler.compile(Workspace) to run the compiler across this workspace of code.

      For example:

      
         try (var workspace = Workspaces.newWorkspace()) {
           workspace
              .createSourcePathPackage()
              .copyContentsFrom("src", "test", "resources", "test-data");
      
           var compilation = someCompiler.compile(workspace);
      
           assertThat(compilation).isSuccessful();
         }
       
      Returns:
      the workspace.
    • newWorkspace

      public static Workspace newWorkspace(PathStrategy pathStrategy)
      Create a new default workspace instance using the given path strategy.

      This workspace must be closed after use. Ideally, you should use a try-with-resources to achieve this. Failing to do this will lead to resources being leaked and tests not being cleared up correctly.

      The workspace can be passed to JctCompiler.compile(Workspace) to run the compiler across this workspace of code.

      For example:

      
         try (var workspace = Workspaces.newWorkspace(PathStrategy.TEMP_DIRECTORIES)) {
           workspace
              .createSourcePathPackage()
              .copyContentsFrom("src", "test", "resources", "test-data");
      
           var compilation = someCompiler.compile(workspace);
      
           assertThat(compilation).isSuccessful();
         }
       
      Parameters:
      pathStrategy - the path strategy to use.
      Returns:
      the workspace.