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 2019/04/17 13:19:34 UTC
[karaf] branch master updated: [KARAF-6232] Introduce
timestampedSnapshot parameter in karaf:add-to-repository to define the
SNAPSHOT version format
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push:
new b373b05 [KARAF-6232] Introduce timestampedSnapshot parameter in karaf:add-to-repository to define the SNAPSHOT version format
new 874197e Merge pull request #817 from jbonofre/KARAF-6232
b373b05 is described below
commit b373b052354d23d5682cd0087699e5145163bb48
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Wed Apr 17 14:02:40 2019 +0200
[KARAF-6232] Introduce timestampedSnapshot parameter in karaf:add-to-repository to define the SNAPSHOT version format
---
.../src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc | 4 ++++
.../apache/karaf/tooling/features/AddToRepositoryMojo.java | 5 ++++-
.../main/java/org/apache/karaf/tooling/utils/MavenUtil.java | 11 ++++++++---
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc b/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc
index 19baf1e..bab060b 100644
--- a/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc
+++ b/manual/src/main/asciidoc/developer-guide/karaf-maven-plugin.adoc
@@ -368,6 +368,10 @@ into the `target/features-repo` directory.
|`repository`
|`File`
|The directory where the bundles will be copied by the plugin goal
+
+|`timestampedSnapshot`
+|`boolean`
+|For SNAPSHOT artifacts, if false we use the base version (foo-1.0-SNAPSHOT), else we use the timestamped version (foo-1.0-2019xxxx). Default value: false
|===
===== `karaf:create-kar`
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddToRepositoryMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddToRepositoryMojo.java
index dfa9447..54f4321 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddToRepositoryMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AddToRepositoryMojo.java
@@ -54,6 +54,9 @@ public class AddToRepositoryMojo extends AbstractFeatureMojo {
@Parameter
protected List<CopyFileBasedDescriptor> copyFileBasedDescriptors;
+ @Parameter(defaultValue = "false")
+ private boolean timestampedSnapshot;
+
public void execute() throws MojoExecutionException, MojoFailureException {
Set<Feature> featuresSet = resolveFeatures();
@@ -129,7 +132,7 @@ public class AddToRepositoryMojo extends AbstractFeatureMojo {
*/
private String getRelativePath(Artifact artifact) {
String dir = (this.flatRepoLayout) ? "" : MavenUtil.getDir(artifact);
- String name = MavenUtil.getFileName(artifact);
+ String name = MavenUtil.getFileName(artifact, timestampedSnapshot);
return dir + name;
}
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MavenUtil.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MavenUtil.java
index 9c4c427..e93a799 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MavenUtil.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MavenUtil.java
@@ -207,9 +207,14 @@ public class MavenUtil {
metadataWriter.write(writer, metadata);
}
- public static String getFileName(Artifact artifact) {
- return artifact.getArtifactId() + "-" + artifact.getVersion()
- + (artifact.getClassifier() != null ? "-" + artifact.getClassifier() : "") + "." + artifact.getType();
+ public static String getFileName(Artifact artifact, boolean timestampedSnapshot) {
+ if (timestampedSnapshot) {
+ return artifact.getArtifactId() + "-" + artifact.getVersion()
+ + (artifact.getClassifier() != null ? "-" + artifact.getClassifier() : "") + "." + artifact.getType();
+ } else {
+ return artifact.getArtifactId() + "-" + artifact.getBaseVersion()
+ + (artifact.getClassifier() != null ? "-" + artifact.getClassifier() : "") + "." + artifact.getType();
+ }
}
public static String getDir(Artifact artifact) {