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

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 9267179  Allow specific manually maintained attributes in component 
adoc headers (#3876)
9267179 is described below

commit 926717904a626b32c0167f8c73ef9d68eb0d68f8
Author: djencks <djen...@apache.org>
AuthorDate: Mon Jun 1 23:21:40 2020 -0700

    Allow specific manually maintained attributes in component adoc headers 
(#3876)
---
 .../camel/maven/packaging/UpdateReadmeMojo.java    | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateReadmeMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateReadmeMojo.java
index f377f25..ff033df 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateReadmeMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateReadmeMojo.java
@@ -23,10 +23,14 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.stream.Stream;
 
 import org.apache.camel.tooling.model.ArtifactModel;
@@ -57,6 +61,10 @@ import org.sonatype.plexus.build.incremental.BuildContext;
 @Mojo(name = "update-readme", threadSafe = true)
 public class UpdateReadmeMojo extends AbstractGeneratorMojo {
 
+    //Header attributes that are preserved through header generation
+    private static final Pattern[] MANUAL_ATTRIBUTES = 
{Pattern.compile(":(group): *(.*)"),
+            Pattern.compile(":(summary-group): *(.*)")};
+
     /**
      * The project build directory
      */
@@ -471,6 +479,21 @@ public class UpdateReadmeMojo extends 
AbstractGeneratorMojo {
                 return false;
             }
 
+            // find manual attributes
+            Map<String, String> manualAttributes = new LinkedHashMap<>();
+            for (String line: lines) {
+                if (line.length() == 0) {
+                    break;
+                }
+                for (Pattern attrName: MANUAL_ATTRIBUTES) {
+                    Matcher m = attrName.matcher(line);
+                    if (m.matches()) {
+                        manualAttributes.put(m.group(1), m.group(2));
+                        break;
+                    }
+                }
+            }
+
             List<String> newLines = new ArrayList<>(lines.length + 8);
 
             //link
@@ -501,6 +524,13 @@ public class UpdateReadmeMojo extends 
AbstractGeneratorMojo {
                 }
             }
 
+            if (!manualAttributes.isEmpty()) {
+                newLines.add("//Manually maintained attributes");
+                for (Map.Entry<String, String> entry: 
manualAttributes.entrySet()) {
+                    newLines.add(":" + entry.getKey() + ": " + 
entry.getValue());
+                }
+            }
+
             newLines.add("");
 
             for (int i = 0; i < lines.length; i++) {

Reply via email to