This is an automated email from the ASF dual-hosted git repository. djencks pushed a commit to branch camel-3.7.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 03f90dffd5d0a212c2c8071711522ef39e254345 Author: David Jencks <djen...@apache.org> AuthorDate: Sat Oct 9 16:00:29 2021 -0700 set up moving new manual attributes to header in UpdateReadmeMojo add shortname to header attributes (tooling) add starter-artifactid to manual attributes --- .../camel/maven/packaging/UpdateReadmeMojo.java | 34 +++++++++++++++++----- 1 file changed, 27 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 92ce6c2..9017d3f 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 @@ -58,15 +58,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 @@ -613,7 +620,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) { @@ -637,6 +644,8 @@ public class UpdateReadmeMojo extends AbstractGeneratorMojo { } newLines.add("= " + title); newLines.add(":docTitle: " + model.getTitle()); + String shortName = "mail".equals(name) ? "imap" : name; + newLines.add(":shortname: " + shortName); if (model instanceof ArtifactModel<?>) { newLines.add(":artifactId: " + ((ArtifactModel<?>) model).getArtifactId()); @@ -679,12 +688,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) {