Created
November 27, 2012 12:27
-
-
Save splatch/4153976 to your computer and use it in GitHub Desktop.
Simple java class which reads assembly component and split it into smaller parts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.FileReader; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| import org.apache.maven.plugin.assembly.model.Component; | |
| import org.apache.maven.plugin.assembly.model.DependencySet; | |
| import org.apache.maven.plugin.assembly.model.FileItem; | |
| import org.apache.maven.plugin.assembly.model.FileSet; | |
| import org.apache.maven.plugin.assembly.model.io.xpp3.ComponentXpp3Reader; | |
| import org.apache.maven.plugin.assembly.model.io.xpp3.ComponentXpp3Writer; | |
| public class Splitter { | |
| public static void main(String[] args) throws Exception { | |
| Map<String, Component> components = new HashMap<String, Component>(); | |
| Component read = new ComponentXpp3Reader().read(new FileReader("src/main/resources/external/assembly-component.xml")); | |
| for (FileItem item : read.getFiles()) { | |
| String outputDirectory = item.getOutputDirectory(); | |
| if (!components.containsKey(outputDirectory)) { | |
| components.put(outputDirectory, new Component()); | |
| } | |
| components.get(outputDirectory).addFile(item); | |
| } | |
| for (FileSet item : read.getFileSets()) { | |
| String outputDirectory = item.getOutputDirectory(); | |
| if (!components.containsKey(outputDirectory)) { | |
| components.put(outputDirectory, new Component()); | |
| } | |
| components.get(outputDirectory).addFileSet(item); | |
| } | |
| for (DependencySet item : read.getDependencySets()) { | |
| String outputDirectory = item.getOutputDirectory(); | |
| if (!components.containsKey(outputDirectory)) { | |
| components.put(outputDirectory, new Component()); | |
| } | |
| components.get(outputDirectory).addDependencySet(item); | |
| } | |
| System.out.println(components.get("/modules/org/milyn/main")); | |
| new ComponentXpp3Writer().write(System.out, components.get("/modules/org/milyn/main")); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment