Interface Workspace

All Superinterfaces:
AutoCloseable

@API(since="0.0.1", status=STABLE) public interface Workspace extends AutoCloseable
Interface for a Workspace to hold files and directories within.

This acts as a nexus for managing the lifetime of test sources and directories, and should be used within a try-with-resources block to ensure temporary files get released after the test completes.

While this interface may seem somewhat intimidating due to the number of methods it provides, you will usually only ever need to use a small subset of them. The main ones you probably will want to use are:

A simple example of usage of this interface would be the following:


 try (Workspace workspace = Workspaces.newWorkspace()) {
   workspace
      .createSourcePathPackage()
      .copyContentsFrom("src", "test", "resources", "test-data");

   var compilation = someCompiler.compile(workspace);

   assertThat(compilation).isSuccessful();
 }
 

As of 3.2.0, you can use a functional version of the above instead if this is more suitable for your use-case:


 Workspaces.newWorkspace().use(workspace -> {
   ...
 });
 

Remember that files that are created as the result of a compilation can be queried via JctFileManager, which is accessible on the compilation result object. This may more accurately represent the logical project structure that is the result of various processing operations during compilation.

Since:
0.0.1
Author:
Ashley Scopes