MavenPomArtifactBuilder extends AbstractArtifactBuilder { @Override public ArtifactBuilder buildArtifacts(BaseArtifactType primaryArtifact, ArtifactContent artifactContent) throws Exception { super.buildArtifacts(primaryArtifact, artifactContent); try { Model model = new MavenXpp3Reader().read(getContentStream()); MavenProject project = new MavenProject(model); ((ExtendedDocument) primaryArtifact).setExtendedType(JavaModel.TYPE_MAVEN_POM_XML); for (String key :project.getProperties().stringPropertyNames()) { String value = project.getProperties().getProperty(key); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PROPERTY + key, value); } if (primaryArtifact.getDescription()==null) primaryArtifact.setDescription(project.getDescription()); if (primaryArtifact.getName()==null) primaryArtifact.setName(project.getName()); if (primaryArtifact.getVersion()==null) primaryArtifact.setVersion(project.getVersion()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_ARTIFACT_ID, model.getArtifactId()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_GROUP_ID, model.getGroupId()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_VERSION, model.getVersion()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PACKAGING, model.getPackaging()); if (model.getParent()!=null) { ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_ARTIFACT_ID, model.getParent().getArtifactId()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_GROUP_ID, model.getParent().getGroupId()); ArtificerModelUtils.setCustomProperty(primaryArtifact, JavaModel.PROP_MAVEN_PARENT_VERSION, model.getParent().getVersion()); } return this; } catch (XmlPullParserException e) { throw new IOException(e.getMessage(),e); } }  @Override ArtifactBuilder buildArtifacts(BaseArtifactType primaryArtifact, ArtifactContent artifactContent); @Override ArtifactBuilder buildRelationships(RelationshipContext context);  }
@Test public void testJavaDeriver() throws Exception { MavenPomArtifactBuilder builder = new MavenPomArtifactBuilder(); ExtendedDocument artifact = new ExtendedDocument(); artifact.setArtifactType(BaseArtifactEnum.EXTENDED_ARTIFACT_TYPE); artifact.setName("pom.xml"); InputStream is = getClass().getResourceAsStream("pom.xml"); @SuppressWarnings("unused") Collection<BaseArtifactType> derivedArtifacts = builder.buildArtifacts(artifact, new ArtifactContent("pom.xml", is)) .getDerivedArtifacts(); is.close(); Assert.assertNotNull(artifact.getProperty()); for (Property property : artifact.getProperty()) { System.out.println(property.getPropertyName() + " - " + property.getPropertyValue()); } System.out.println(artifact.getDescription()); }