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

djencks pushed a commit to branch camel-3.12.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3716f5e0347bf0e222b1c7946bbea970b6f24ba9
Author: David Jencks <[email protected]>
AuthorDate: Sat Oct 9 16:00:29 2021 -0700

    set up moving new manual attributes to header in UpdateReadmeMojo
    
    add starter-artifactid to manual attributes
---
 .../camel/maven/packaging/UpdateReadmeMojo.java    | 32 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 7 deletions(-)

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 b25adbb..59dad536 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
@@ -67,15 +67,22 @@ import org.sonatype.plexus.build.incremental.BuildContext;
 import static org.apache.camel.tooling.util.PackageHelper.findCamelDirectory;
 
 /**
- * Generate or updates the component/dataformat/language/eip readme.md and 
.adoc files in the project root directory.
+ * Generate or updates the component/dataformat/language/eip documentation 
.adoc files in the project src/main/docs
+ * directory.
  */
 @Mojo(name = "update-readme", threadSafe = true)
 public class UpdateReadmeMojo extends AbstractGeneratorMojo {
 
+    //Set to true if you need to move a new manual attribute from text body to 
header attributes.
+    private static final boolean RELOCATE_MANUAL_ATTRIBUTES = false;
+
     //Header attributes that are preserved through header generation
     private static final Pattern[] MANUAL_ATTRIBUTES = {
             Pattern.compile(":(group): *(.*)"),
-            Pattern.compile(":(summary-group): *(.*)") };
+            Pattern.compile(":(summary-group): *(.*)"),
+            Pattern.compile(":(camel-spring-boot-name): *(.*)"),
+            Pattern.compile(":(starter-artifactid): *(.*)")
+    };
 
     /**
      * The project build directory
@@ -457,7 +464,7 @@ public class UpdateReadmeMojo extends AbstractGeneratorMojo 
{
             // find manual attributes
             Map<String, String> manualAttributes = new LinkedHashMap<>();
             for (String line : lines) {
-                if (line.length() == 0) {
+                if (!RELOCATE_MANUAL_ATTRIBUTES && line.length() == 0) {
                     break;
                 }
                 for (Pattern attrName : MANUAL_ATTRIBUTES) {
@@ -525,12 +532,23 @@ public class UpdateReadmeMojo extends 
AbstractGeneratorMojo {
             }
 
             boolean copy = false;
-            if (updated) {
-                for (int i = 0; i < lines.length; i++) {
-                    if (!copy && lines[i].isEmpty()) {
+            if (updated || RELOCATE_MANUAL_ATTRIBUTES) {
+                outer: for (String line : lines) {
+                    if (!copy && line.isEmpty()) {
                         copy = true;
                     } else if (copy) {
-                        newLines.add(lines[i]);
+
+                        if (RELOCATE_MANUAL_ATTRIBUTES) {
+                            for (Pattern attrName : MANUAL_ATTRIBUTES) {
+                                Matcher m = attrName.matcher(line);
+                                if (m.matches()) {
+                                    updated = true;
+                                    continue outer;
+                                }
+                            }
+                        }
+
+                        newLines.add(line);
                     }
                 }
                 if (!copy) {

Reply via email to