Skip to content

Commit 031a95b

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 586251d commit 031a95b

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

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

103107
DefaultContext context = new DefaultContext();
104108

105-
context.put("basedir", getBasedir());
109+
context.put("basedir", getTestBasedir());
106110

107111
customizeContext(context);
108112

@@ -170,6 +174,29 @@ public void afterEach(ExtensionContext context) throws Exception {
170174
}
171175
}
172176

177+
/**
178+
* The base directory for the test instance. By default, this is the same as the basedir.
179+
*
180+
* @return the testBasedir
181+
* @since 1.7.0
182+
*/
183+
protected String getTestBasedir() {
184+
if (testBasedir == null) {
185+
testBasedir = getBasedir();
186+
}
187+
return testBasedir;
188+
}
189+
190+
/**
191+
* Set the base directory for the test instance. By default, this is the same as the basedir.
192+
*
193+
* @param testBasedir the testBasedir for the test instance
194+
* @since 1.7.0
195+
*/
196+
protected void setTestBasedir(String testBasedir) {
197+
this.testBasedir = testBasedir;
198+
}
199+
173200
public PlexusContainer getContainer() {
174201
if (container == null) {
175202
setupContainer();

0 commit comments

Comments
 (0)