karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [2/2] git commit: Fix update of etc/startup.properties depending of the scope
Date Tue, 23 Sep 2014 19:18:09 GMT
Fix update of etc/startup.properties depending of the scope


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/39748c78
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/39748c78
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/39748c78

Branch: refs/heads/karaf-3.0.x
Commit: 39748c78fb12dc4c03e08691af32e6d54346499d
Parents: 69fe0b8
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Tue Sep 23 21:17:28 2014 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Tue Sep 23 21:17:28 2014 +0200

----------------------------------------------------------------------
 .../developers-guide/custom-distribution.conf   | 25 ++++++++++++----
 .../karaf/tooling/features/InstallKarsMojo.java | 30 +++++++++-----------
 2 files changed, 32 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/39748c78/manual/src/main/webapp/developers-guide/custom-distribution.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/developers-guide/custom-distribution.conf b/manual/src/main/webapp/developers-guide/custom-distribution.conf
index 56228c3..312c0a7 100644
--- a/manual/src/main/webapp/developers-guide/custom-distribution.conf
+++ b/manual/src/main/webapp/developers-guide/custom-distribution.conf
@@ -15,18 +15,31 @@ This custom distribution could contain:
 
 h2. Maven assembly
 
-The recommended way to create a Karaf server assembly is to use the karaf-assembly packaging
with the karaf-maven-plugin.  This assembles a server from the maven dependencies in the project
pom.  After explanation of the configuration options we present an example.  The Karaf project
effectively uses this packaging to assemble the official Karaf distributions, but due to maven
limitations we have to simulate rather than use the karaf-assembly packaging.
+The recommended way to create a Karaf server assembly is to use the karaf-assembly packaging
with the karaf-maven-plugin.
+It assembles a server from the maven dependencies in the project pom.
+After explanation of the configuration options we present an example.
 
-This packaging creates tar.gz and zip archives containing the assembled server.  They are
identical except that zip archives don't unpack with appropriate unix file permissions for
the scripts.
+The Karaf project effectively uses this packaging to assemble the official Karaf distributions,
but due to maven
+limitations we have to simulate rather than use the karaf-assembly packaging.
+
+This packaging creates tar.gz and zip archives containing the assembled server.
+They are identical except that zip archives don't unpack with appropriate unix file permissions
for the scripts.
 
 h3. Maven dependencies
-Maven dependencies in a karaf-assembly project can be feature repositories (classifier "features")
or kar archives.  Feature repositories are installed in the internal "system" Maven structured
repository.  Kar archives have their content unpacked on top of the server as well as contained
feature repositories installed.
 
-The Maven scope of a dependency determines whether its feature repository is listed in the
features service configuration file etc/org.apache.karaf.features.cfg featuresRepositories
property:
+Maven dependencies in a karaf-assembly project can be feature repositories (classifier "features")
or kar archives.
+
+Feature repositories are installed in the internal "system" Maven structured repository.
+
+Kar archives have their content unpacked on top of the server as well as contained feature
repositories installed.
+
+The Maven scope of a dependency determines whether its feature repository is listed in the
features service configuration
+file etc/org.apache.karaf.features.cfg featuresRepositories property:
 
-compile (default): All the features in the repository (or for a kar repositories) will be
installed into the startup.properties.  The feature repo is not listed in the features service
configuration file.
+compile (default): All the features in the repository (or for a kar repositories) will be
installed into the startup.properties.
 
-runtime: feature installation is controlled by <startupFeature>, <bootFeature>,
and <installedFeature> elements in the karaf-maven-plugin configuration. The feature
repo uri is listed in the features service configuration file.
+runtime: feature installation is controlled by <startupFeature>, <bootFeature>,
and <installedFeature> elements in the karaf-maven-plugin configuration.
+The feature repo uri is listed in the features service configuration file.
 
 h3. Plugin configuration
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/39748c78/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 8d4f6f5..256867a 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
@@ -25,13 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 import org.apache.felix.utils.properties.Properties;
 import org.apache.karaf.features.BundleInfo;
@@ -160,11 +154,13 @@ public class InstallKarsMojo extends MojoSupport {
         }
 
         Set<String> repositories = new HashSet<String>();
-        Set<Feature> features = new HashSet<Feature>();
+        Map<Feature, Boolean> features = new HashMap<Feature, Boolean>();
 
         getLog().info("Loading kar and features dependency in compile and runtime scopes");
         Collection<Artifact> dependencies = project.getDependencyArtifacts();
         for (Artifact artifact : dependencies) {
+            getLog().info("The startup.properties file is updated using kar and features
dependency with a scope different from runtime, or defined in the <startupFeatures/>
element");
+            boolean addToStartup = !artifact.getScope().equals("runtime");
             if (artifact.getScope().equals("compile") || artifact.getScope().equals("runtime"))
{
                 if (artifact.getType().equals("kar")) {
                     File karFile = artifact.getFile();
@@ -173,7 +169,7 @@ public class InstallKarsMojo extends MojoSupport {
                         Kar kar = new Kar(karFile.toURI());
                         kar.extract(new File(system.getPath()), new File(workDirectory));
                         for (URI repositoryUri : kar.getFeatureRepos()) {
-                            resolveRepository(repositoryUri.getPath(), repositories, features,
true);
+                            resolveRepository(repositoryUri.getPath(), repositories, features,
true, addToStartup);
                         }
                     } catch (Exception e) {
                         throw new RuntimeException("Can not install " + artifact.toString()
+ " kar", e);
@@ -183,7 +179,7 @@ public class InstallKarsMojo extends MojoSupport {
                         getLog().info("Resolving " + artifact.toString() + " features repository");
                         String repositoryUri = dependencyHelper.artifactToMvn(artifact);
                         try {
-                            resolveRepository(repositoryUri, repositories, features, true);
+                            resolveRepository(repositoryUri, repositories, features, true,
addToStartup);
                         } catch (Exception e) {
                             throw new MojoFailureException("Can not install " + artifact.toString()
+ " features repository", e);
                         }
@@ -193,10 +189,10 @@ public class InstallKarsMojo extends MojoSupport {
         }
 
         // install features/bundles
-        for (Feature feature : features) {
+        for (Feature feature : features.keySet()) {
             getLog().info("Install " + feature.getName() + " feature");
             try {
-                if (startupFeatures != null && startupFeatures.contains(feature.getName()))
{
+                if (features.get(feature) || (startupFeatures != null && startupFeatures.contains(feature.getName())))
{
                     // the feature is a startup feature, updating startup.properties file
                     getLog().info("= Feature " + feature.getName() + " is defined as a startup
feature");
                     getLog().info("= Updating startup.properties file");
@@ -281,7 +277,7 @@ public class InstallKarsMojo extends MojoSupport {
         }
     }
 
-    private void resolveRepository(String repository, Set<String> repositories, Set<Feature>
features, boolean updateFeaturesCfgFile) throws Exception {
+    private void resolveRepository(String repository, Set<String> repositories, Map<Feature,
Boolean> features, boolean updateFeaturesCfgFile, boolean updateStartupProperties) throws
Exception {
         // check if the repository has not been processed
         if (repositories.contains(repository)) {
             return;
@@ -335,17 +331,17 @@ public class InstallKarsMojo extends MojoSupport {
         Features featuresModel = JaxbUtil.unmarshal(new FileInputStream(repositoryFile),
false);
         // recursively process the inner repositories
         for (String innerRepository : featuresModel.getRepository()) {
-            resolveRepository(innerRepository, repositories, features, false);
+            resolveRepository(innerRepository, repositories, features, false, updateStartupProperties);
         }
         // update features
         for (Feature feature : featuresModel.getFeature()) {
-            features.add(feature);
+            features.put(feature, updateStartupProperties);
         }
     }
 
-    private void resolveFeature(Feature feature, Set<Feature> features) throws Exception
{
+    private void resolveFeature(Feature feature, Map<Feature, Boolean> features) throws
Exception {
         for (Dependency dependency : feature.getFeature()) {
-            for (Feature f : features) {
+            for (Feature f : features.keySet()) {
                 if (f.getName().equals(dependency.getName())) {
                     resolveFeature(f, features);
                 }


Mime
View raw message