@@ -71,6 +71,11 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback {
7171
7272 private static String basedir ;
7373
74+ /**
75+ * The base directory for the test instance
76+ */
77+ private String testBasedir ;
78+
7479 static {
7580 if (System .getProperty ("guice_custom_class_loading" , "" ).trim ().isEmpty ()) {
7681 System .setProperty ("guice_custom_class_loading" , "CHILD" );
@@ -79,7 +84,6 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback {
7984
8085 @ Override
8186 public void beforeEach (ExtensionContext context ) throws Exception {
82- basedir = getBasedir ();
8387
8488 setContext (context );
8589
@@ -101,7 +105,7 @@ protected void setupContainer() {
101105
102106 DefaultContext context = new DefaultContext ();
103107
104- context .put ("basedir" , getBasedir ());
108+ context .put ("basedir" , getTestBasedir ());
105109
106110 customizeContext (context );
107111
@@ -185,6 +189,29 @@ public void afterEach(ExtensionContext context) throws Exception {
185189 }
186190 }
187191
192+ /**
193+ * The base directory for the test instance. By default, this is the same as the basedir.
194+ *
195+ * @return the testBasedir
196+ * @since 1.7.0
197+ */
198+ protected String getTestBasedir () {
199+ if (testBasedir == null ) {
200+ testBasedir = getBasedir ();
201+ }
202+ return testBasedir ;
203+ }
204+
205+ /**
206+ * Set the base directory for the test instance. By default, this is the same as the basedir.
207+ *
208+ * @param testBasedir the testBasedir for the test instance
209+ * @since 1.7.0
210+ */
211+ protected void setTestBasedir (String testBasedir ) {
212+ this .testBasedir = testBasedir ;
213+ }
214+
188215 public PlexusContainer getContainer () {
189216 if (container == null ) {
190217 setupContainer ();
0 commit comments