in src/main/java/org/apache/maven/plugins/shade/resource/ComponentsXmlResourceTransformer.java [56:121]
public void processResource(String resource, InputStream is, List<Relocator> relocators, long time)
throws IOException {
Xpp3Dom newDom;
try {
BufferedInputStream bis = new BufferedInputStream(is) {
@Override
public void close() throws IOException {
// leave ZIP open
}
};
Reader reader = ReaderFactory.newXmlReader(bis);
newDom = Xpp3DomBuilder.build(reader);
} catch (Exception e) {
throw new IOException("Error parsing components.xml in " + is, e);
}
// Only try to merge in components if there are some elements in the component-set
if (newDom.getChild("components") == null) {
return;
}
Xpp3Dom[] children = newDom.getChild("components").getChildren("component");
for (Xpp3Dom component : children) {
String role = getValue(component, "role");
role = getRelocatedClass(role, relocators);
setValue(component, "role", role);
String roleHint = getValue(component, "role-hint");
String impl = getValue(component, "implementation");
impl = getRelocatedClass(impl, relocators);
setValue(component, "implementation", impl);
String key = role + ':' + roleHint;
if (components.containsKey(key)) {
// TODO: use the tools in Plexus to merge these properly. For now, I just need an all-or-nothing
// configuration carry over
Xpp3Dom dom = components.get(key);
if (dom.getChild("configuration") != null) {
component.addChild(dom.getChild("configuration"));
}
}
Xpp3Dom requirements = component.getChild("requirements");
if (requirements != null && requirements.getChildCount() > 0) {
for (int r = requirements.getChildCount() - 1; r >= 0; r--) {
Xpp3Dom requirement = requirements.getChild(r);
String requiredRole = getValue(requirement, "role");
requiredRole = getRelocatedClass(requiredRole, relocators);
setValue(requirement, "role", requiredRole);
}
}
components.put(key, component);
}
if (time > this.time) {
this.time = time;
}
}