Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tooling/karaf-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.2.7</version>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import javax.inject.Inject;
import javax.inject.Named;

/**
* Assemble a kar archive from a features.xml file
Expand All @@ -75,7 +75,8 @@ public class KarMojo extends MojoSupport {
/**
* The Jar archiver.
*/
@Component(role = Archiver.class, hint="jar")
@Inject
@Named("jar")
private JarArchiver jarArchiver = null;

/**
Expand Down Expand Up @@ -264,6 +265,7 @@ private File createArchive(List<Artifact> bundles, File featuresFile, String gro
// configure for Reproducible Builds based on outputTimestamp value
archiver.configureReproducible(outputTimestamp);

List<File> tempMetadataFiles = new ArrayList<>();
try {
//TODO should .kar be a bundle?
// archive.addManifestEntry(Constants.BUNDLE_NAME, project.getName());
Expand Down Expand Up @@ -345,12 +347,7 @@ private File createArchive(List<Artifact> bundles, File featuresFile, String gro
}

jarArchiver.addFile(metadataTmp, repositoryPath + layout.pathOf(artifact).substring(0, layout.pathOf(artifact).lastIndexOf('/')) + "/maven-metadata-local.xml");

try {
metadataTmp.delete();
} catch (final Exception ex) {
getLog().warn("Cannot delete temporary created file.", ex);
}
tempMetadataFiles.add(metadataTmp);
}

String targetFileName = repositoryPath + layout.pathOf(artifact);
Expand All @@ -362,6 +359,16 @@ private File createArchive(List<Artifact> bundles, File featuresFile, String gro
}
archiver.createArchive(mavenSession, project, archive);

for (File tempMetadataFile : tempMetadataFiles) {
try {
if (!tempMetadataFile.delete()) {
getLog().warn("Cannot delete temporary created file: " + tempMetadataFile.getAbsolutePath());
}
} catch (final Exception ex) {
getLog().warn("Cannot delete temporary created file: " + tempMetadataFile.getAbsolutePath(), ex);
}
}

return archiveFile;
} catch (Exception e) {
throw new MojoExecutionException("Failed to create archive", e);
Expand Down
Loading