You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2015/11/24 21:24:12 UTC
[1/2] karaf git commit: [KARAF-4145] KAR Mojo: fix metadata
generation of artifacts
Repository: karaf
Updated Branches:
refs/heads/master fce8292d5 -> 91749c92d
[KARAF-4145] KAR Mojo: fix metadata generation of artifacts
Problem description:
* use the kmp to generate a kar that contains snapshot version
* use the kmp to generate a custom distribution that fills the local
repository of the distribution with the content of that kar
* try to install the snapshot artifact (not using any other repository
then the system directory
* if your snapshots has been timestamped and a maven metadata XML does
not exist on KAR creation the installation of the artifact will fail
The KAR Mojo contains a workaround to use the base version of a snapshot
instead of a timestamped one because it does not work in
startup.properties.
The metadata that is used for a snapshot artifact is generated (if not
present) using the timestamped version. Also if there exists already a
metadata, we can not use them without further checking for the
version...
Let's move the version fix in front of the metadata generation and
generate the metadata for every snapshot.
Signed-off-by: Markus Rathgeb <ma...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/85e882d9
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/85e882d9
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/85e882d9
Branch: refs/heads/master
Commit: 85e882d99c03e92aa98a3228aa4c6a224ee86f78
Parents: cdc236c
Author: Markus Rathgeb <ma...@gmail.com>
Authored: Tue Nov 24 17:28:14 2015 +0100
Committer: Markus Rathgeb <ma...@gmail.com>
Committed: Tue Nov 24 19:46:36 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/karaf/tooling/KarMojo.java | 35 +++++++++++---------
1 file changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/85e882d9/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/KarMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/KarMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/KarMojo.java
index 6b3f9a9..5d712bd 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/KarMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/KarMojo.java
@@ -299,28 +299,33 @@ public class KarMojo extends MojoSupport {
for (Artifact artifact : bundles) {
artifactResolver.resolve(artifact, remoteRepos, localRepo);
- File localFile = artifact.getFile();
+
+ //TODO this may not be reasonable, but... resolved snapshot artifacts have timestamped versions
+ //which do not work in startup.properties.
+ artifact.setVersion(artifact.getBaseVersion());
if (artifact.isSnapshot()) {
// the artifact is a snapshot, create the maven-metadata-local.xml
- File metadataTarget = new File(localFile.getParentFile(), "maven-metadata-local.xml");
- if (!metadataTarget.exists()) {
- // the maven-metadata-local.xml doesn't exist, create it
- try {
- MavenUtil.generateMavenMetadata(artifact, metadataTarget);
- } catch (Exception e) {
- getLog().warn("Could not create maven-metadata-local.xml", e);
- getLog().warn("It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
- }
+ final File metadataTmp = File.createTempFile("maven-metadata-local.xml", ".tmp");
+
+ try {
+ MavenUtil.generateMavenMetadata(artifact, metadataTmp);
+ } catch (Exception e) {
+ getLog().warn("Could not create maven-metadata-local.xml", e);
+ getLog().warn("It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
+ }
+
+ 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);
}
- jarArchiver.addFile(metadataTarget, repositoryPath + layout.pathOf(artifact).substring(0, layout.pathOf(artifact).lastIndexOf('/')) + "/maven-metadata-local.xml");
}
- //TODO this may not be reasonable, but... resolved snapshot artifacts have timestamped versions
- //which do not work in startup.properties.
- artifact.setVersion(artifact.getBaseVersion());
String targetFileName = repositoryPath + layout.pathOf(artifact);
- jarArchiver.addFile(localFile, targetFileName);
+ jarArchiver.addFile(artifact.getFile(), targetFileName);
}
if (resourcesDir.isDirectory()) {
[2/2] karaf git commit: Merge branch 'kmp-kar-snapshots' of
https://github.com/maggu2810/karaf
Posted by jb...@apache.org.
Merge branch 'kmp-kar-snapshots' of https://github.com/maggu2810/karaf
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/91749c92
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/91749c92
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/91749c92
Branch: refs/heads/master
Commit: 91749c92d6aea7f95a5e6c74b655d9c2f9c359fe
Parents: fce8292 85e882d
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Tue Nov 24 21:10:33 2015 +0100
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Tue Nov 24 21:10:33 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/karaf/tooling/KarMojo.java | 35 +++++++++++---------
1 file changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------