Skip to content

Commit 2a0f1d6

Browse files
Add testBasedir property
We have basedir property which is static, we need new filed which will be not static and connected with current test instance.
1 parent 13b3d77 commit 2a0f1d6

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/main/java/org/codehaus/plexus/testing/PlexusExtension.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)