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
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte

@Override
public void beforeEach(ExtensionContext context) throws Exception {
// TODO provide protected setters in PlexusExtension
Field field = PlexusExtension.class.getDeclaredField("basedir");
field.setAccessible(true);
String basedir = AnnotationSupport.findAnnotation(context.getElement().get(), Basedir.class)
.map(Basedir::value)
.orElse(getBasedir());
field.set(null, basedir);
.orElse(null);

setTestBasedir(basedir);

setContext(context);

Expand Down Expand Up @@ -167,13 +165,6 @@ public void beforeEach(ExtensionContext context) throws Exception {
}
}

@Override
public void afterEach(ExtensionContext context) throws Exception {
Field field = PlexusExtension.class.getDeclaredField("basedir");
field.setAccessible(true);
field.set(null, null);
}

/**
* Default MojoExecution mock
*
Expand Down Expand Up @@ -210,7 +201,7 @@ private Mojo lookupMojo(
String[] coord = mojoCoordinates(goal);
Xpp3Dom pomDom;
if (pom.startsWith("file:")) {
Path path = Paths.get(getBasedir()).resolve(pom.substring("file:".length()));
Path path = Paths.get(getTestBasedir()).resolve(pom.substring("file:".length()));
pomDom = Xpp3DomBuilder.build(new XmlStreamReader(path.toFile()));
} else if (pom.startsWith("classpath:")) {
URL url = holder.getResource(pom.substring("classpath:".length()));
Expand All @@ -221,7 +212,7 @@ private Mojo lookupMojo(
} else if (pom.contains("<project>")) {
pomDom = Xpp3DomBuilder.build(new StringReader(pom));
} else {
Path path = Paths.get(getBasedir()).resolve(pom);
Path path = Paths.get(getTestBasedir()).resolve(pom);
pomDom = Xpp3DomBuilder.build(new XmlStreamReader(path.toFile()));
}
Xpp3Dom pluginConfiguration = extractPluginConfiguration(coord[1], pomDom);
Expand All @@ -245,7 +236,7 @@ protected String[] mojoCoordinates(String goal) throws Exception {
if (goal.matches(".*:.*:.*:.*")) {
return goal.split(":");
} else {
Path pluginPom = Paths.get(getBasedir(), "pom.xml");
Path pluginPom = Paths.get(getTestBasedir(), "pom.xml");
Xpp3Dom pluginPomDom = Xpp3DomBuilder.build(new XmlStreamReader(pluginPom.toFile()));
String artifactId = pluginPomDom.getChild("artifactId").getValue();
String groupId = resolveFromRootThenParent(pluginPomDom, "groupId");
Expand Down