karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [3/3] karaf git commit: [KARAF-4752] Support for logback, easier framework switching and defaulting
Date Tue, 22 Nov 2016 13:34:01 GMT
[KARAF-4752] Support for logback, easier framework switching and defaulting

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

Branch: refs/heads/master
Commit: 46b26566fc81f14113f0df215240563c1f5ae270
Parents: 58f7098
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Tue Nov 22 11:36:40 2016 +0100
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Tue Nov 22 14:33:35 2016 +0100

----------------------------------------------------------------------
 assemblies/apache-karaf-minimal/pom.xml         |  1 -
 assemblies/apache-karaf/pom.xml                 |  1 -
 .../framework/src/main/feature/feature.xml      | 16 ++++++
 .../static/src/main/feature/feature.xml         |  8 +++
 .../apache/karaf/profile/assembly/Builder.java  |  1 +
 .../org/apache/karaf/tooling/AssemblyMojo.java  | 53 ++++++++++++++++++++
 .../org/apache/karaf/tooling/VerifyMojo.java    | 10 ++--
 7 files changed, 84 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/46b26566/assemblies/apache-karaf-minimal/pom.xml
----------------------------------------------------------------------
diff --git a/assemblies/apache-karaf-minimal/pom.xml b/assemblies/apache-karaf-minimal/pom.xml
index ac20996..f3583df 100644
--- a/assemblies/apache-karaf-minimal/pom.xml
+++ b/assemblies/apache-karaf-minimal/pom.xml
@@ -122,7 +122,6 @@
                         <feature>wrapper</feature>
                     </installedFeatures>
                     <bootFeatures>
-                        <feature>framework</feature>
                         <feature>jaas</feature>
                         <feature>shell</feature>
                         <feature>feature</feature>

http://git-wip-us.apache.org/repos/asf/karaf/blob/46b26566/assemblies/apache-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/assemblies/apache-karaf/pom.xml b/assemblies/apache-karaf/pom.xml
index 758a090..b433185 100644
--- a/assemblies/apache-karaf/pom.xml
+++ b/assemblies/apache-karaf/pom.xml
@@ -169,7 +169,6 @@
                         <feature>eventadmin</feature>
                     </startupFeatures>
                     <bootFeatures>
-                        <feature>framework</feature>
                         <feature>wrap</feature>
                         <feature>aries-blueprint</feature>
                         <feature>shell</feature>

http://git-wip-us.apache.org/repos/asf/karaf/blob/46b26566/assemblies/features/framework/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/framework/src/main/feature/feature.xml b/assemblies/features/framework/src/main/feature/feature.xml
index de7947b..6dbe1a1 100644
--- a/assemblies/features/framework/src/main/feature/feature.xml
+++ b/assemblies/features/framework/src/main/feature/feature.xml
@@ -37,4 +37,20 @@
         <bundle start="true" start-level="15">mvn:org.apache.karaf.features/org.apache.karaf.features.core/${project.version}</bundle>
     </feature>
 
+    <feature version="${project.version}" description="Karaf core feature" name="framework-logback"
hidden="true">
+        <!-- persistent wiring extension -->
+        <bundle start="true" start-level="1">mvn:org.apache.karaf.features/org.apache.karaf.features.extension/${project.version}</bundle>
+        <!-- mvn: and wrap: url handlers -->
+        <bundle start="true" start-level="5">mvn:org.ops4j.pax.url/pax-url-aether/${pax.url.version}</bundle>
+        <!-- logging -->
+        <bundle start="true" start-level="8">mvn:org.ops4j.pax.logging/pax-logging-api/${pax.logging.version}</bundle>
+        <bundle start="true" start-level="8">mvn:org.ops4j.pax.logging/pax-logging-logback/${pax.logging.version}</bundle>
+        <!-- config admin -->
+        <bundle start="true" start-level="10">mvn:org.apache.felix/org.apache.felix.configadmin/${felix.configadmin.version}</bundle>
+        <!-- file install -->
+        <bundle start="true" start-level="11">mvn:org.apache.felix/org.apache.felix.fileinstall/${felix.fileinstall.version}</bundle>
+        <!-- features service -->
+        <bundle start="true" start-level="15">mvn:org.apache.karaf.features/org.apache.karaf.features.core/${project.version}</bundle>
+    </feature>
+
 </features>

http://git-wip-us.apache.org/repos/asf/karaf/blob/46b26566/assemblies/features/static/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/static/src/main/feature/feature.xml b/assemblies/features/static/src/main/feature/feature.xml
index 8f191a5..375f75e 100644
--- a/assemblies/features/static/src/main/feature/feature.xml
+++ b/assemblies/features/static/src/main/feature/feature.xml
@@ -26,4 +26,12 @@
         <bundle start="true" start-level="10">mvn:org.apache.karaf.services/org.apache.karaf.services.staticcm/${project.version}</bundle>
     </feature>
 
+    <feature version="${project.version}" description="Karaf core feature" name="static-framework-logback">
+        <!-- logging -->
+        <bundle start="true" start-level="8">mvn:org.ops4j.pax.logging/pax-logging-api/${pax.logging.version}</bundle>
+        <bundle start="true" start-level="8">mvn:org.ops4j.pax.logging/pax-logging-logback/${pax.logging.version}</bundle>
+        <!-- static config admin -->
+        <bundle start="true" start-level="10">mvn:org.apache.karaf.services/org.apache.karaf.services.staticcm/${project.version}</bundle>
+    </feature>
+
 </features>

http://git-wip-us.apache.org/repos/asf/karaf/blob/46b26566/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 d55b230..bba1427 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
@@ -522,6 +522,7 @@ public class Builder {
 
         // Generate profiles
         Profile startupProfile = generateProfile(Stage.Startup, profiles, repositories, features,
bundles);
+        profiles.put(startupProfile.getId(), Stage.Boot);
         Profile bootProfile = generateProfile(Stage.Boot, profiles, repositories, features,
bundles);
         Profile installedProfile = generateProfile(Stage.Installed, profiles, repositories,
features, bundles);
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/46b26566/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
index 8880f98..ee2c587 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/AssemblyMojo.java
@@ -20,6 +20,7 @@ package org.apache.karaf.tooling;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.attribute.PosixFilePermissions;
@@ -27,6 +28,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import org.apache.karaf.profile.assembly.Builder;
 import org.apache.karaf.tooling.utils.IoUtils;
@@ -185,6 +187,13 @@ public class AssemblyMojo extends MojoSupport {
     protected String javase;
 
     /**
+     * Specify which framework to use
+     * (one of framework, framework-logback, static-framework, static-framework-logback).
+     */
+    @Parameter
+    protected String framework;
+
+    /**
      * Specify an XML file that instructs this goal to apply edits to
      * one or more standard Karaf property files.
      * The contents of this file are documented in detail on
@@ -414,6 +423,50 @@ public class AssemblyMojo extends MojoSupport {
             builder.libraries(libraries.toArray(new String[libraries.size()]));
         }
         // Startup
+        boolean hasFrameworkKar = false;
+        for (String kar : startupKars) {
+            if (kar.startsWith("mvn:org.apache.karaf.features/framework/")
+                    || kar.startsWith("mvn:org.apache.karaf.features/static/")) {
+                hasFrameworkKar = true;
+                startupKars.remove(kar);
+                if (framework == null) {
+                    framework = kar.startsWith("mvn:org.apache.karaf.features/framework/")
+                            ? "framework" : "static-framework";
+                }
+                builder.kars(Builder.Stage.Startup, false, kar);
+                break;
+            }
+        }
+        if (!hasFrameworkKar) {
+            Properties versions = new Properties();
+            try (InputStream is = getClass().getResourceAsStream("versions.properties"))
{
+                versions.load(is);
+            } catch (IOException e) {
+                throw new IllegalStateException(e);
+            }
+            String realKarafVersion = versions.getProperty("karaf-version");
+            String kar;
+            switch (framework) {
+                case "framework":
+                    kar = "mvn:org.apache.karaf.features/framework/" + realKarafVersion +
"/xml/features";
+                    break;
+                case "framework-logback":
+                    kar = "mvn:org.apache.karaf.features/framework/" + realKarafVersion +
"/xml/features";
+                    break;
+                case "static-framework":
+                    kar = "mvn:org.apache.karaf.features/static/" + realKarafVersion + "/xml/features";
+                    break;
+                case "static-framework-logback":
+                    kar = "mvn:org.apache.karaf.features/static/" + realKarafVersion + "/xml/features";
+                    break;
+                default:
+                    throw new IllegalArgumentException("Unsupported framework: " + framework);
+            }
+            builder.kars(Builder.Stage.Startup, false, kar);
+        }
+        if (!startupFeatures.contains(framework)) {
+            builder.features(Builder.Stage.Startup, framework);
+        }
         builder.defaultStage(Builder.Stage.Startup)
                .kars(toArray(startupKars))
                .repositories(startupFeatures.isEmpty() && startupProfiles.isEmpty()
&& installAllFeaturesByDefault, toArray(startupRepositories))

http://git-wip-us.apache.org/repos/asf/karaf/blob/46b26566/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
index b6b1194..1c212c1 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
@@ -251,18 +251,20 @@ public class VerifyMojo extends MojoSupport {
             }
         }
 
+        Set<String> allDescriptors = new LinkedHashSet<>();
         if (descriptors == null) {
             if (framework == null) {
                 framework = Collections.singleton("framework");
             }
             descriptors = new LinkedHashSet<>();
             if (framework.contains("framework")) {
-                descriptors.add("mvn:org.apache.karaf.features/framework/" + getVersion("org.apache.karaf.features:framework")
+ "/xml/features");
+                allDescriptors.add("mvn:org.apache.karaf.features/framework/" + getVersion("org.apache.karaf.features:framework")
+ "/xml/features");
             }
-            descriptors.add("file:" + project.getBuild().getDirectory() + "/feature/feature.xml");
+            allDescriptors.add("file:" + project.getBuild().getDirectory() + "/feature/feature.xml");
         } else {
+            allDescriptors.addAll(descriptors);
             if (framework != null && framework.contains("framework")) {
-                descriptors.add("mvn:org.apache.karaf.features/framework/" + getVersion("org.apache.karaf.features:framework")
+ "/xml/features");
+                allDescriptors.add("mvn:org.apache.karaf.features/framework/" + getVersion("org.apache.karaf.features:framework")
+ "/xml/features");
             }
         }
 
@@ -272,7 +274,7 @@ public class VerifyMojo extends MojoSupport {
         final Map<String, Features> repositories;
         Map<String, List<Feature>> allFeatures = new HashMap<>();
         try {
-            repositories = loadRepositories(manager, descriptors);
+            repositories = loadRepositories(manager, allDescriptors);
             for (String repoUri : repositories.keySet()) {
                 List<Feature> features = repositories.get(repoUri).getFeature();
                 // Ack features to inline configuration files urls


Mime
View raw message