use of org.codehaus.plexus.util.xml.Xpp3Dom in project maven-plugins by apache.
the class IntegrationTestUtils method initPluginInfo.
private static void initPluginInfo() throws IOException {
URL resource = Thread.currentThread().getContextClassLoader().getResource("META-INF/maven/plugin.xml");
Reader reader = null;
try {
reader = new InputStreamReader(resource.openStream());
Xpp3Dom pluginDom;
pluginDom = Xpp3DomBuilder.build(reader);
reader.close();
reader = null;
pluginArtifactId = pluginDom.getChild("artifactId").getValue();
pluginGroupId = pluginDom.getChild("groupId").getValue();
pluginVersion = pluginDom.getChild("version").getValue();
cliPluginPrefix = pluginGroupId + ":" + pluginArtifactId + ":" + pluginVersion + ":";
} catch (XmlPullParserException e) {
throw (IOException) new IOException("Failed to parse plugin descriptor for groupId:artifactId:version prefix.").initCause(e);
} finally {
close(reader);
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project maven-plugins by apache.
the class PluginXmlResourceTransformer method processResource.
public void processResource(String resource, InputStream is, List<Relocator> relocators) throws IOException {
Xpp3Dom newDom;
try {
BufferedInputStream bis = new BufferedInputStream(is) {
public void close() throws IOException {
// leave ZIP open
}
};
Reader reader = ReaderFactory.newXmlReader(bis);
newDom = Xpp3DomBuilder.build(reader);
} catch (Exception e) {
throw (IOException) new IOException("Error parsing plugin.xml in " + is).initCause(e);
}
// Only try to merge in mojos if there are some elements in the plugin
if (newDom.getChild("mojos") == null) {
return;
}
for (Xpp3Dom mojo : newDom.getChild("mojos").getChildren("mojo")) {
String impl = getValue(mojo, "implementation");
impl = getRelocatedClass(impl, relocators);
setValue(mojo, "implementation", impl);
Xpp3Dom parameters = mojo.getChild("parameters");
if (parameters != null) {
for (Xpp3Dom parameter : parameters.getChildren()) {
String type = getValue(parameter, "type");
type = getRelocatedClass(type, relocators);
setValue(parameter, "type", type);
}
}
Xpp3Dom configuration = mojo.getChild("configuration");
if (configuration != null) {
for (Xpp3Dom configurationEntry : configuration.getChildren()) {
String implementation = getAttribute(configurationEntry, "implementation");
implementation = getRelocatedClass(implementation, relocators);
setAttribute(configurationEntry, "implementation", implementation);
}
}
Xpp3Dom requirements = mojo.getChild("requirements");
if (requirements != null && requirements.getChildCount() > 0) {
for (Xpp3Dom requirement : requirements.getChildren()) {
String requiredRole = getValue(requirement, "role");
requiredRole = getRelocatedClass(requiredRole, relocators);
setValue(requirement, "role", requiredRole);
}
}
mojos.add(mojo);
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project maven-plugins by apache.
the class PluginXmlResourceTransformer method setValue.
private static void setValue(Xpp3Dom dom, String element, String value) {
Xpp3Dom child = dom.getChild(element);
if (child == null || value == null || value.length() <= 0) {
return;
}
child.setValue(value);
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project maven-plugins by apache.
the class ComponentsXmlArchiverFileFilter method addComponentsXml.
void addComponentsXml(final Reader componentsReader) throws XmlPullParserException, IOException {
Xpp3Dom newDom = Xpp3DomBuilder.build(componentsReader);
if (newDom != null) {
newDom = newDom.getChild("components");
}
if (newDom != null) {
final Xpp3Dom[] children = newDom.getChildren();
for (final Xpp3Dom component : children) {
if (components == null) {
components = new LinkedHashMap<String, Xpp3Dom>();
}
final String role = component.getChild("role").getValue();
final Xpp3Dom child = component.getChild("role-hint");
final String roleHint = child != null ? child.getValue() : "";
final String key = role + roleHint;
if (!components.containsKey(key)) {
components.put(key, component);
}
}
}
}
use of org.codehaus.plexus.util.xml.Xpp3Dom in project bndtools by bndtools.
the class MavenWorkspaceRepository method getBundleFile.
private File getBundleFile(final MavenProject mavenProject) {
String finalName = null;
// first check maven-jar-plugin config first, if it is empty use project.build.finalName
Plugin jarPlugin = mavenProject.getPlugin("org.apache.maven.plugins:maven-jar-plugin");
if (jarPlugin != null) {
Object config = jarPlugin.getConfiguration();
if (config instanceof Xpp3Dom) {
Xpp3Dom dom = (Xpp3Dom) config;
Xpp3Dom finalNameNode = dom.getChild("finalName");
if (finalNameNode != null) {
finalName = finalNameNode.getValue();
}
}
}
if (finalName == null) {
finalName = mavenProject.getBuild().getFinalName();
}
return new File(mavenProject.getBuild().getDirectory(), finalName + ".jar");
}
Aggregations