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 2023/01/14 06:52:10 UTC

[karaf] branch main updated: [KARAF-7637] drop non-reproducible properties store

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new 9fdca2a55a [KARAF-7637] drop non-reproducible properties store
     new a4d055ab4a Merge pull request #1710 from hboutemy/KARAF-7637
9fdca2a55a is described below

commit 9fdca2a55a70c1a8af3a2f70be00721be87531dd
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Fri Jan 13 23:52:22 2023 +0100

    [KARAF-7637] drop non-reproducible properties store
---
 archetypes/assembly/pom.xml                        |  2 +-
 archetypes/blueprint/pom.xml                       |  2 +-
 archetypes/bundle/pom.xml                          |  2 +-
 archetypes/command/pom.xml                         |  2 +-
 archetypes/feature/pom.xml                         |  2 +-
 archetypes/kar/pom.xml                             |  2 +-
 .../tooling/tracker/GenerateServiceMetadata.java   | 30 ++++++++++++++++++++--
 7 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/archetypes/assembly/pom.xml b/archetypes/assembly/pom.xml
index a661ea58b7..36f6871a88 100644
--- a/archetypes/assembly/pom.xml
+++ b/archetypes/assembly/pom.xml
@@ -34,7 +34,7 @@
     <description>This archetype sets up an empty karaf assembly project.</description>
 
     <properties>
-        <archetype.version>3.1.2</archetype.version>
+        <archetype.version>3.2.1</archetype.version>
     </properties>
 
     <build>
diff --git a/archetypes/blueprint/pom.xml b/archetypes/blueprint/pom.xml
index 91d6e05846..9b30c5b530 100644
--- a/archetypes/blueprint/pom.xml
+++ b/archetypes/blueprint/pom.xml
@@ -35,7 +35,7 @@
     <description>An archetype for creating a simple blueprint bundle.</description>
 
     <properties>
-        <archetype.version>3.1.2</archetype.version>
+        <archetype.version>3.2.1</archetype.version>
     </properties>
 
     <build>
diff --git a/archetypes/bundle/pom.xml b/archetypes/bundle/pom.xml
index eb30398705..6fdf760d04 100644
--- a/archetypes/bundle/pom.xml
+++ b/archetypes/bundle/pom.xml
@@ -35,7 +35,7 @@
     <description>A simple bundle archetype.</description>
 
     <properties>
-        <archetype.version>3.1.2</archetype.version>
+        <archetype.version>3.2.1</archetype.version>
     </properties>
 
     <build>
diff --git a/archetypes/command/pom.xml b/archetypes/command/pom.xml
index 1225ebd867..fd60247cb3 100644
--- a/archetypes/command/pom.xml
+++ b/archetypes/command/pom.xml
@@ -35,7 +35,7 @@
     <description>A Karaf command archetype.</description>
 
     <properties>
-        <archetype.version>3.1.2</archetype.version>
+        <archetype.version>3.2.1</archetype.version>
     </properties>
 
     <build>
diff --git a/archetypes/feature/pom.xml b/archetypes/feature/pom.xml
index c5d8595686..fc1fce21ae 100644
--- a/archetypes/feature/pom.xml
+++ b/archetypes/feature/pom.xml
@@ -35,7 +35,7 @@
     <description>This archetype sets up an empty karaf features project.</description>
 
     <properties>
-        <archetype.version>3.1.2</archetype.version>
+        <archetype.version>3.2.1</archetype.version>
     </properties>
 
     <build>
diff --git a/archetypes/kar/pom.xml b/archetypes/kar/pom.xml
index ec1f20af4c..dfd302bb2e 100644
--- a/archetypes/kar/pom.xml
+++ b/archetypes/kar/pom.xml
@@ -35,7 +35,7 @@
     <description>This archetype sets up an empty karaf kar project.</description>
 
     <properties>
-        <archetype.version>3.1.2</archetype.version>
+        <archetype.version>3.2.1</archetype.version>
     </properties>
 
     <build>
diff --git a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
index 17903303f5..f0eb59a2d8 100644
--- a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
+++ b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
@@ -16,12 +16,18 @@
  */
 package org.apache.karaf.tooling.tracker;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 import java.util.Set;
@@ -176,8 +182,28 @@ public class GenerateServiceMetadata extends AbstractMojo {
 
         File file = new File(outputDirectory, "OSGI-INF/karaf-tracker/" + serviceClazz.getName());
         file.getParentFile().mkdirs();
-        try (OutputStream os = buildContext.newFileOutputStream(file)) {
-            props.store(os, null);
+        writeProperties(props, file);
+    }
+
+    private void writeProperties(Properties props, File file) throws IOException {
+        try (OutputStream os = buildContext.newFileOutputStream(file); PrintWriter pw = new PrintWriter(new OutputStreamWriter(os, "ISO-8859-1"));
+             StringWriter sw = new StringWriter()) {
+            props.store(sw, null);
+
+            List<String> lines = new ArrayList<>();
+            try (BufferedReader r = new BufferedReader(new StringReader(sw.toString()))) {
+                String line;
+                while ((line = r.readLine()) != null) {
+                    if (!line.startsWith("#")) {
+                        lines.add(line);
+                    }
+                }
+            }
+
+            Collections.sort(lines);
+            for (String l : lines) {
+                pw.println(l);
+            }
         }
     }