if (newOutput.exists()) {
newOutput.delete();
}
JarFile bundle = null;
JarFileResourceStore store = null;
try {
Artifact artifact = project.getArtifact();
if (artifact.getFile() == null || !artifact.getFile().exists() || !artifact.getFile().isFile()) {
throw new IOException("Error loading jar file for maven artifact "+artifact.getId());
}
bundle = new JarFile(artifact.getFile());
store = new JarFileResourceStore(bundle,newOutput);
Manifest manifest = bundle.getManifest();
String componentHeader = manifest.getMainAttributes().getValue("iPOJO-Components");
if (componentHeader == null) {
return;
}
Element metadata = ManifestMetadataParser.parseHeaderMetadata(componentHeader);
store.setManifest(bundle.getManifest());
ComponentDeclaration template = getVersionedComponentTemplate(artifact);
EnrichElementsHelper.addPropertiesToChildrenApAMComponents(metadata, template.getPropertyDefinitions(), template.getProperties());
DefaultManifestBuilder builder = new DefaultManifestBuilder();
builder.setMetadataRenderer(new MetadataRenderer());
builder.addMetada(Arrays.asList(metadata.getElements()));
store.setManifestBuilder(builder);
} catch (Exception e) {
getLog().error(e.getMessage(), e);
throw new MojoExecutionException(e.getMessage());
}
finally {
try {
if (store != null)
store.close();
}
catch(Exception ignored) {
}
try {
if (bundle != null)