diff --git a/src/main/java/org/codehaus/plexus/testing/PlexusExtension.java b/src/main/java/org/codehaus/plexus/testing/PlexusExtension.java index b344041..d02cbbc 100644 --- a/src/main/java/org/codehaus/plexus/testing/PlexusExtension.java +++ b/src/main/java/org/codehaus/plexus/testing/PlexusExtension.java @@ -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"); @@ -79,7 +84,6 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback { @Override public void beforeEach(ExtensionContext context) throws Exception { - basedir = getBasedir(); setContext(context); @@ -102,7 +106,7 @@ protected void setupContainer() { DefaultContext context = new DefaultContext(); - context.put("basedir", getBasedir()); + context.put("basedir", getTestBasedir()); customizeContext(context); @@ -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();