Code Snippet :
package com.bnp.pomparser;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.List;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
public class ParseMe {
public static void main(String[] args) throws IOException, XmlPullParserException {
Reader reader = new FileReader("POM_XML_PATH");
try {
MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
Model model = xpp3Reader.read(reader);
List<Dependency> dependencyList = model.getDependencies();
for(Dependency
dependency : dependencyList){
System.out.println("Group Id :: "+dependency.getGroupId());
System.out.println("Artifact Id :: "+dependency.getArtifactId());
System.out.println("Version Id :: "+dependency.getVersion());
}
}
finally {
reader.close();
}
}
}
No comments:
Post a Comment