I'm developing a code-sharing plugin for eclipse (for a bachelor thesis project).
Currently I'm trying to scan a maven repository and generate a package list.
I can download and parse a pom.xml using the maven.model classes, but I can't figure out which maven classes are responsible for parsing of archetype-catalog.xml
Is there a non maven parser?
Can I just scan the entire repository tree for pom.xml files?
edit: Ive found nexus-indexer but i have no idea hot to use it :(
It took ages but i finally found a working example
PlexusContainer plexus = new DefaultPlexusContainer();
NexusIndexer n = (NexusIndexer) plexus.lookup(NexusIndexer.class);
IndexUpdater iu = (IndexUpdater) plexus.lookup(IndexUpdater.class);
// DefaultNexusIndexer n = new DefaultNexusIndexer();
List<IndexCreator> indexCreators = new ArrayList<IndexCreator>();
// IndexingContext c = n.addIndexingContext("test", "test",new File( "/home/tomas/Desktop/test"),new File( "/home/tomas/Desktop/index"), "http://repository.jboss.org/", null);
Directory tempIndexDirectory = new RAMDirectory();
// IndexCreator min = new MinimalArtifactInfoIndexCreator();
// MavenPluginArtifactInfoIndexCreator mavenPlugin = new MavenPluginArtifactInfoIndexCreator();
// MavenArchetypeArtifactInfoIndexCreator mavenArchetype = new MavenArchetypeArtifactInfoIndexCreator();
// JarFileContentsIndexCreator jar = new JarFileContentsIndexCreator();
// IndexCreator min = plexus.lookup(IndexCreator.class, MinimalArtifactInfoIndexCreator.ID);
IndexCreator mavenPlugin = plexus.lookup( IndexCreator.class, MavenPluginArtifactInfoIndexCreator.ID );
IndexCreator mavenArchetype = plexus.lookup( IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID );
IndexCreator jar = plexus.lookup( IndexCreator.class, JarFileContentsIndexCreator.ID );
indexCreators.add(min);
indexCreators.add(mavenPlugin);
indexCreators.add(mavenArchetype);
indexCreators.add(jar);
IndexingContext c = n.addIndexingContext(
"temp", "test", new File("/home/tomas/Desktop/mavenTest"),
tempIndexDirectory, "http://repository.jboss.org/maven2/",
null, indexCreators
);
IndexUpdateRequest ur=new IndexUpdateRequest(c);
ur.setForceFullUpdate(true);
iu.fetchAndUpdateIndex(ur);
// for (String s : c.getAllGroups()) {
// System.out.println(s);
// }
BooleanQuery q = new BooleanQuery();
q.add(n.constructQuery(ArtifactInfo.GROUP_ID, "*"), Occur.SHOULD);
FlatSearchRequest request = new FlatSearchRequest(q);
FlatSearchResponse response = n.searchFlat(request);
for (ArtifactInfo a : response.getResults()) {
String bUrl=url+a`enter code here`.groupId+"/"+a.artifactId+"/"+a.version+"/";
String fileName=a.artifactId+"-"+a.version;
System.out.println(bUrl+fileName+"."+a.packaging);
}