use of aQute.bnd.maven.PomParser in project bnd by bndtools.
the class MavenTest method testPomParser.
/**
* Test the pom parser which will turn the pom into a set of properties,
* which will make it actually readable according to some.
*
* @throws Exception
*/
@SuppressWarnings("restriction")
public static void testPomParser() throws Exception {
PomParser parser = new PomParser();
Properties p = parser.getProperties(IO.getFile("testresources/ws/maven1/pom.xml"));
p.store(System.err, "testing");
assertEquals("Apache Felix Metatype Service", p.get("pom.name"));
// is from
assertEquals("org.apache.felix", p.get("pom.groupId"));
// parent
assertEquals("org.apache.felix.metatype", p.get("pom.artifactId"));
assertEquals("bundle", p.get("pom.packaging"));
Parameters map = parser.parseHeader(p.getProperty("pom.scope.test"));
Map<String, String> junit = map.get("junit.junit");
assertNotNull(junit);
assertEquals("4.0", junit.get("version"));
Map<String, String> easymock = map.get("org.easymock.easymock");
assertNotNull(easymock);
assertEquals("2.4", easymock.get("version"));
}
use of aQute.bnd.maven.PomParser in project bnd by bndtools.
the class Domain method domain.
public static Domain domain(File file) throws IOException {
if (file.getName().endsWith(".mf")) {
try (InputStream in = IO.stream(file)) {
Manifest m = new Manifest(in);
return domain(m);
}
}
if (file.getName().endsWith(".properties") || file.getName().endsWith(".bnd")) {
Processor p = new Processor();
p.setProperties(file);
return domain(p);
}
if (file.getName().endsWith(".pom")) {
try {
PomParser p = new PomParser();
p.setProperties(p.getProperties(file));
return domain(p);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
// default & last. Assume JAR
try (JarInputStream jin = new JarInputStream(IO.stream(file))) {
Manifest m = jin.getManifest();
if (m != null)
return domain(m);
}
try (ZipFile zf = new ZipFile(file)) {
ZipEntry entry = zf.getEntry("META-INF/MANIFEST.MF");
if (entry == null)
return null;
Manifest m = new Manifest(zf.getInputStream(entry));
return domain(m);
} catch (ZipException e) {
return null;
}
}
Aggregations