You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2015/03/10 15:03:21 UTC
[8/8] karaf git commit: [KARAF-3589] Support boot features version
syntax for 2.x and 3.x
[KARAF-3589] Support boot features version syntax for 2.x and 3.x
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/668db818
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/668db818
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/668db818
Branch: refs/heads/master
Commit: 668db818bb875c21610b8b5480b0503585c59586
Parents: d27a84f
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Tue Mar 10 14:33:29 2015 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Tue Mar 10 15:02:40 2015 +0100
----------------------------------------------------------------------
.../apache/karaf/profile/assembly/Builder.java | 68 ++++++++++++--------
.../karaf/tooling/features/InstallKarsMojo.java | 4 +-
2 files changed, 42 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/668db818/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index 101737e..70a4e85 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -107,12 +107,16 @@ public class Builder {
public static enum Stage {
Startup, Boot, Installed
}
-
+
+ public static enum KarafVersion {
+ v24, v3x, v4x
+ }
+
static class RepositoryInfo {
Stage stage;
boolean addAll;
}
-
+
//
// Input parameters
//
@@ -127,9 +131,9 @@ public class Builder {
Map<String, Stage> bundles = new LinkedHashMap<>();
List<String> libraries = new ArrayList<>();
String javase = "1.7";
+ KarafVersion karafVersion = KarafVersion.v4x;
String environment = null;
boolean useReferenceUrls;
- boolean use24SyntaxForStartup;
boolean ignoreDependencyFlag;
int defaultStartLevel = 50;
Path homeDirectory;
@@ -263,12 +267,8 @@ public class Builder {
return this;
}
- public Builder use24SyntaxForStartup() {
- return use24SyntaxForStartup(true);
- }
-
- public Builder use24SyntaxForStartup(boolean use24SyntaxForStartup) {
- this.use24SyntaxForStartup = use24SyntaxForStartup;
+ public Builder karafVersion(KarafVersion karafVersion) {
+ this.karafVersion = karafVersion;
return this;
}
@@ -611,7 +611,11 @@ public class Builder {
Dependency dep = generatedDep.get(dependency);
if (dep == null) {
dep = new Dependency();
- dep.setName(dependency);
+ String[] split = dependency.split("/");
+ dep.setName(split[0]);
+ if (split.length > 1) {
+ dep.setVersion(split[1]);
+ }
generated.getFeature().add(dep);
generatedDep.put(dep.getName(), dep);
}
@@ -714,7 +718,7 @@ public class Builder {
JaxbUtil.marshal(rep, baos);
ByteArrayInputStream bais;
String repoUrl;
- if (use24SyntaxForStartup) {
+ if (karafVersion == KarafVersion.v24) {
String str = baos.toString();
str = str.replace("http://karaf.apache.org/xmlns/features/v1.3.0", "http://karaf.apache.org/xmlns/features/v1.2.0");
str = str.replaceAll(" dependency=\".*?\"", "");
@@ -740,40 +744,48 @@ public class Builder {
featuresProperties.save();
}
else {
- String boot = "";
+ StringBuilder boot = new StringBuilder();
for (Dependency dep : generatedDep.values()) {
if (dep.isPrerequisite()) {
- if (boot.isEmpty()) {
- boot = "(";
+ if (boot.length() == 0) {
+ boot.append("(");
} else {
- boot = boot + ",";
+ boot.append(",");
}
- boot = boot + dep.getName();
+ boot.append(dep.getName());
}
}
- if (!boot.isEmpty()) {
- boot = boot + ")";
+ if (boot.length() > 0) {
+ boot.append(")");
}
// TODO: for dependencies, we'd need to resolve the features completely
for (Dependency dep : generatedDep.values()) {
if (!dep.isPrerequisite() && !dep.isDependency()) {
- if (!boot.isEmpty()) {
- boot = boot + ",";
+ if (boot.length() > 0) {
+ boot.append(",");
+ }
+ boot.append(dep.getName());
+ if (!Feature.DEFAULT_VERSION.equals(dep.getVersion())) {
+ if (karafVersion == KarafVersion.v4x) {
+ boot.append("/");
+ } else {
+ boot.append(";version=");
+ }
+ boot.append(dep.getVersion());
}
- boot = boot + dep.getName();
}
}
- String repos = "";
+ StringBuilder repos = new StringBuilder();
for (String repo : new HashSet<>(rep.getRepository())) {
- if (!repos.isEmpty()) {
- repos = repos + ",";
+ if (repos.length() > 0) {
+ repos.append(",");
}
- repos = repos + repo;
+ repos.append(repo);
}
Properties featuresProperties = new Properties(featuresCfgFile.toFile());
- featuresProperties.put(FEATURES_REPOSITORIES, repos);
- featuresProperties.put(FEATURES_BOOT, boot);
+ featuresProperties.put(FEATURES_REPOSITORIES, repos.toString());
+ featuresProperties.put(FEATURES_BOOT, boot.toString());
reformatClauses(featuresProperties, FEATURES_REPOSITORIES);
reformatClauses(featuresProperties, FEATURES_BOOT);
featuresProperties.save();
@@ -816,7 +828,7 @@ public class Builder {
if (location.startsWith("file:") && useReferenceUrls) {
location = "reference:" + location;
}
- if (location.startsWith("file:") && use24SyntaxForStartup) {
+ if (location.startsWith("file:") && karafVersion == KarafVersion.v24) {
location = location.substring("file:".length());
}
startup.put(location, startLevel);
http://git-wip-us.apache.org/repos/asf/karaf/blob/668db818/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
index 559a155..0a629a4 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/InstallKarsMojo.java
@@ -138,7 +138,7 @@ public class InstallKarsMojo extends MojoSupport {
protected boolean installAllFeaturesByDefault = true;
@Parameter
- protected boolean use24SyntaxForStartup = false;
+ protected Builder.KarafVersion karafVersion = Builder.KarafVersion.v4x;
// an access layer for available Aether implementation
protected DependencyHelper dependencyHelper;
@@ -237,7 +237,7 @@ public class InstallKarsMojo extends MojoSupport {
}
}
- builder.use24SyntaxForStartup(use24SyntaxForStartup)
+ builder.karafVersion(karafVersion)
.useReferenceUrls(useReferenceUrls)
.defaultAddAll(installAllFeaturesByDefault)
.ignoreDependencyFlag(ignoreDependencyFlag);