in maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java [158:190]
private Mojo lookupMojo(
Class<?> holder, InjectMojo injectMojo, List<MojoParameter> mojoParameters, PluginDescriptor descriptor)
throws Exception {
String goal = injectMojo.goal();
String pom = injectMojo.pom();
String[] coord = mojoCoordinates(goal);
Xpp3Dom pomDom;
if (pom.startsWith("file:")) {
Path path = Paths.get(getBasedir()).resolve(pom.substring("file:".length()));
pomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(path.toFile()));
} else if (pom.startsWith("classpath:")) {
URL url = holder.getResource(pom.substring("classpath:".length()));
if (url == null) {
throw new IllegalStateException("Unable to find pom on classpath: " + pom);
}
pomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(url.openStream()));
} else if (pom.contains("<project>")) {
pomDom = Xpp3DomBuilder.build(new StringReader(pom));
} else {
Path path = Paths.get(getBasedir()).resolve(pom);
pomDom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(path.toFile()));
}
XmlNode pluginConfiguration = extractPluginConfiguration(coord[1], pomDom);
if (!mojoParameters.isEmpty()) {
List<XmlNode> children = mojoParameters.stream()
.map(mp -> new XmlNodeImpl(mp.name(), mp.value()))
.collect(Collectors.toList());
XmlNode config = new XmlNodeImpl("configuration", null, null, children, null);
pluginConfiguration = XmlNode.merge(config, pluginConfiguration);
}
Mojo mojo = lookupMojo(coord, pluginConfiguration, descriptor);
return mojo;
}