Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/main/java/org/codehaus/plexus/testing/PlexusExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback {

private static String basedir;

/**
* The base directory for the test instance
*/
private String testBasedir;

static {
if (System.getProperty("guice_custom_class_loading", "").trim().isEmpty()) {
System.setProperty("guice_custom_class_loading", "CHILD");
Expand All @@ -79,7 +84,6 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback {

@Override
public void beforeEach(ExtensionContext context) throws Exception {
basedir = getBasedir();

setContext(context);

Expand All @@ -102,7 +106,7 @@ protected void setupContainer() {

DefaultContext context = new DefaultContext();

context.put("basedir", getBasedir());
context.put("basedir", getTestBasedir());

customizeContext(context);

Expand Down Expand Up @@ -170,6 +174,29 @@ public void afterEach(ExtensionContext context) throws Exception {
}
}

/**
* The base directory for the test instance. By default, this is the same as the basedir.
*
* @return the testBasedir
* @since 1.7.0
*/
protected String getTestBasedir() {
if (testBasedir == null) {
testBasedir = getBasedir();
}
return testBasedir;
}

/**
* Set the base directory for the test instance. By default, this is the same as the basedir.
*
* @param testBasedir the testBasedir for the test instance
* @since 1.7.0
*/
protected void setTestBasedir(String testBasedir) {
this.testBasedir = testBasedir;
}

public PlexusContainer getContainer() {
if (container == null) {
setupContainer();
Expand Down