From 42e024ec780a331e72a5818a2ee22374bb65be36 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Fri, 26 Nov 2021 14:26:14 +0100 Subject: [PATCH] Correctly fix the multiLine tag --- docs/index.md | 10 +++++----- .../license-plugin-report.xml | 2 +- .../license-plugin-report.xml | 2 +- .../license-plugin-report.xml | 2 +- .../4.2-SNAPSHOT/license-plugin-report.xml | 2 +- .../maven/plugin/license/HeaderStyle.java | 6 +++--- .../license/header/HeaderDefinition.java | 18 +++++++++--------- .../plugin/license/header/HeaderType.java | 6 +++--- .../license/AdditionalHeaderMojoTest.java | 2 +- .../header/AdditionalHeaderDefinitionTest.java | 6 +++--- .../check/def/additionalHeaderDefinitions.xml | 4 ++-- .../issue-71-additionalHeaderDefinitions.xml | 2 +- .../update/issue37/license-xml-definition.xml | 2 +- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/index.md b/docs/index.md index f7b3c3c77..502e12602 100644 --- a/docs/index.md +++ b/docs/index.md @@ -545,7 +545,7 @@ In license-maven-plugin, each header style is defined by patterns to detect it a (\s|\t)*/\*.*$ .*\*/(\s|\t)*$ false - true + true false @@ -565,7 +565,7 @@ And for XML: (\s|\t)*$]]> false - true + true false @@ -587,7 +587,7 @@ This page will show you how you can define extended header definitions to fit yo #region.*^EOL/\*\*.*$ \*/EOL#endregion" true - true + true ``` @@ -595,7 +595,7 @@ This page will show you how you can define extended header definitions to fit yo * The `EOL` string will be replaced with the proper end of line depending the file format your are processing. * We also have defined the _skipLine_ attribute to skip the region tags (which starts with a '#') * `allowBlankLines` allows you to define if this header style supports blank lines in it or not. In example, in XML headers, you could have blank lines after the because XML delimiters delimit a multiline block. When you work with script style comments like in Ruby, Porperties files, the # character delimit a comment for only one line. So when you create the header, for it to be uniform, you place # on each line. So allowBlankLines will be false. -* `isMultiline` specifies if your header has tokens to delimit a multiline comment of if the tokens are a one-line comment. I.E.: XML style comments are multiline whereas script style comment where each line starts with # are not multiline +* `multiline` specifies if your header has tokens to delimit a multiline comment of if the tokens are a one-line comment. I.E.: XML style comments are multiline whereas script style comment where each line starts with # are not multiline You now have to add this new header definition file to the plugin configuration. It is done as the following in your pom: @@ -658,7 +658,7 @@ The following example will redefine the header file for text files: \:\( \:\( false - false + false diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/license-plugin-report.xml b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/license-plugin-report.xml index 8839f81ad..fe4efc446 100644 --- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/license-plugin-report.xml +++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-git/license-plugin-report.xml @@ -1,5 +1,5 @@ - + diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-svn/license-plugin-report.xml b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-svn/license-plugin-report.xml index d7df4a3eb..896602545 100644 --- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin-svn/license-plugin-report.xml +++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin-svn/license-plugin-report.xml @@ -1,5 +1,5 @@ - + diff --git a/docs/reports/4.2-SNAPSHOT/license-maven-plugin/license-plugin-report.xml b/docs/reports/4.2-SNAPSHOT/license-maven-plugin/license-plugin-report.xml index 018e64697..cf04f91c9 100644 --- a/docs/reports/4.2-SNAPSHOT/license-maven-plugin/license-plugin-report.xml +++ b/docs/reports/4.2-SNAPSHOT/license-maven-plugin/license-plugin-report.xml @@ -1,5 +1,5 @@ - + diff --git a/docs/reports/4.2-SNAPSHOT/license-plugin-report.xml b/docs/reports/4.2-SNAPSHOT/license-plugin-report.xml index 2f36705d7..7c61246f0 100644 --- a/docs/reports/4.2-SNAPSHOT/license-plugin-report.xml +++ b/docs/reports/4.2-SNAPSHOT/license-plugin-report.xml @@ -1,5 +1,5 @@ - + diff --git a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/HeaderStyle.java b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/HeaderStyle.java index 8be5d7891..1cd87dd94 100644 --- a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/HeaderStyle.java +++ b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/HeaderStyle.java @@ -61,8 +61,8 @@ public class HeaderStyle { *

* A style that is not multi-line is usually repeating in each line the characters before and after each line to delimit a one-line comment. */ - @Parameter - public boolean multiline = true; + @Parameter(alias = "multiline") + public boolean multiLine = true; /** * Only for multi-line comments: specify if blank lines are allowed. @@ -101,6 +101,6 @@ public class HeaderStyle { public String lastLineDetectionPattern; public HeaderDefinition toHeaderDefinition() { - return new HeaderDefinition(name, firstLine, beforeEachLine, endLine, afterEachLine, skipLinePattern, firstLineDetectionPattern, lastLineDetectionPattern, allowBlankLines, multiline, padLines); + return new HeaderDefinition(name, firstLine, beforeEachLine, endLine, afterEachLine, skipLinePattern, firstLineDetectionPattern, lastLineDetectionPattern, allowBlankLines, multiLine, padLines); } } diff --git a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderDefinition.java b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderDefinition.java index 8a8cb5a6e..4be490d1f 100755 --- a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderDefinition.java +++ b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderDefinition.java @@ -35,7 +35,7 @@ public final class HeaderDefinition { private Pattern skipLinePattern; private Pattern firstLineDetectionPattern; private Pattern lastLineDetectionPattern; - private Boolean isMultiline; + private Boolean multiLine; private boolean padLines = false; @@ -60,7 +60,7 @@ public HeaderDefinition(String type, String endLine, String afterEachLine, String skipLinePattern, String firstLineDetectionPattern, String lastLineDetectionPattern, - boolean allowBlankLines, boolean isMultiline, boolean padLines) { + boolean allowBlankLines, boolean multiLine, boolean padLines) { this(type); this.firstLine = firstLine; this.beforeEachLine = beforeEachLine; @@ -70,11 +70,11 @@ public HeaderDefinition(String type, this.firstLineDetectionPattern = compile(firstLineDetectionPattern); this.lastLineDetectionPattern = compile(lastLineDetectionPattern); this.allowBlankLines = allowBlankLines; - this.isMultiline = isMultiline; + this.multiLine = multiLine; this.padLines = padLines; if (!"unknown".equals(type)) validate(); - if (allowBlankLines && !isMultiline) { - throw new IllegalArgumentException("Header style " + type + " is configured to allow blank lines, so it should be set as a multiline header style"); + if (allowBlankLines && !multiLine) { + throw new IllegalArgumentException("Header style " + type + " is configured to allow blank lines, so it should be set as a multi-line header style"); } } @@ -178,8 +178,8 @@ public void setPropertyFromString(String property, String value) { firstLine = value; else if ("allowBlankLines".equalsIgnoreCase(property)) allowBlankLines = Boolean.valueOf(value); - else if ("isMultiline".equalsIgnoreCase(property)) - isMultiline = Boolean.valueOf(value); + else if ("multiLine".equalsIgnoreCase(property) || "isMultiline".equalsIgnoreCase(property)) + multiLine = Boolean.valueOf(value); else if ("beforeEachLine".equalsIgnoreCase(property)) beforeEachLine = value; else if ("endLine".equalsIgnoreCase(property)) @@ -210,7 +210,7 @@ public void validate() { check("afterEachLine", this.afterEachLine); check("firstLineDetectionPattern", this.firstLineDetectionPattern); check("lastLineDetectionPattern", this.lastLineDetectionPattern); - check("isMultiline", this.isMultiline); + check("multiLine", this.multiLine); check("allowBlankLines", this.allowBlankLines); // skip line can be null } @@ -256,6 +256,6 @@ public String toString() { } public boolean isMultiLine() { - return isMultiline; + return multiLine; } } diff --git a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderType.java b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderType.java index afc6a5d8a..3c5a9795b 100755 --- a/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderType.java +++ b/license-maven-plugin/src/main/java/com/mycila/maven/plugin/license/header/HeaderType.java @@ -30,7 +30,7 @@ public enum HeaderType { ////////// COMMENT TYPES ////////// ////////// COMMENT TYPES ////////// - // firstLine beforeEachLine endLine afterEachLine skipLinePattern firstLineDetectionPattern lastLineDetectionPattern allowBlankLines isMultiline padLines + // firstLine beforeEachLine endLine afterEachLine skipLinePattern firstLineDetectionPattern lastLineDetectionPattern allowBlankLines multiLine padLines //generic ASCIIDOC_STYLE("////", " // ", "////EOL", "", null, "^////$", "^////$", false, true, false), MVEL_STYLE("@comment{", " ", "}", "", null, "@comment\\{$", "\\}$", true, true, false), @@ -85,8 +85,8 @@ public enum HeaderType { private HeaderType(String firstLine, String beforeEachLine, String endLine, String afterEachLine, String skipLinePattern, String firstLineDetectionPattern, String lastLineDetectionPattern, - boolean allowBlankLines, boolean isMultiline, boolean padLines) { - definition = new HeaderDefinition(this.name().toLowerCase(), firstLine, beforeEachLine, endLine, afterEachLine, skipLinePattern, firstLineDetectionPattern, lastLineDetectionPattern, allowBlankLines, isMultiline, padLines); + boolean allowBlankLines, boolean multiLine, boolean padLines) { + definition = new HeaderDefinition(this.name().toLowerCase(), firstLine, beforeEachLine, endLine, afterEachLine, skipLinePattern, firstLineDetectionPattern, lastLineDetectionPattern, allowBlankLines, multiLine, padLines); } /** diff --git a/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/AdditionalHeaderMojoTest.java b/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/AdditionalHeaderMojoTest.java index 240cd1f0c..9e6be9197 100755 --- a/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/AdditionalHeaderMojoTest.java +++ b/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/AdditionalHeaderMojoTest.java @@ -73,7 +73,7 @@ public void test_inline() throws Exception { style.firstLineDetectionPattern = "\\:\\("; style.lastLineDetectionPattern = "\\:\\("; style.allowBlankLines = false; - style.multiline = false; + style.multiLine = false; check.defaultInlineHeaderStyles = new HeaderStyle[]{style}; check.mapping = Collections.singletonMap("txt", "smiley"); diff --git a/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/header/AdditionalHeaderDefinitionTest.java b/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/header/AdditionalHeaderDefinitionTest.java index f9079d032..32b294a4c 100755 --- a/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/header/AdditionalHeaderDefinitionTest.java +++ b/license-maven-plugin/src/test/java/com/mycila/maven/plugin/license/header/AdditionalHeaderDefinitionTest.java @@ -40,7 +40,7 @@ public void test_load_definitions() throws Exception { .addTag("firstLineDetectionPattern").addText("\\(\\:") .addTag("lastLineDetectionPattern").addText("\\:\\)") .addTag("allowBlankLines").addText("false") - .addTag("isMultiline").addText("false"); + .addTag("multiLine").addText("false"); System.out.println(def.toString()); @@ -69,7 +69,7 @@ public void test_load_definitions2() throws Exception { .addTag("firstLineDetectionPattern").addText("\\:\\(") .addTag("lastLineDetectionPattern").addText("\\:\\(") .addTag("allowBlankLines").addText("false") - .addTag("isMultiline").addText("false"); + .addTag("multiLine").addText("false"); System.out.println(def.toString()); @@ -90,7 +90,7 @@ public void test_advanced_definitions() throws Exception { .addTag("firstLineDetectionPattern").addText("#region.*^EOL/\\*\\*.*$") .addTag("lastLineDetectionPattern").addText("\\*/EOL#endregion") .addTag("allowBlankLines").addText("false") - .addTag("isMultiline").addText("false"); + .addTag("multiLine").addText("false"); AdditionalHeaderDefinition loader = new AdditionalHeaderDefinition(def); diff --git a/license-maven-plugin/src/test/resources/check/def/additionalHeaderDefinitions.xml b/license-maven-plugin/src/test/resources/check/def/additionalHeaderDefinitions.xml index 941ad965b..3fd626c20 100755 --- a/license-maven-plugin/src/test/resources/check/def/additionalHeaderDefinitions.xml +++ b/license-maven-plugin/src/test/resources/check/def/additionalHeaderDefinitions.xml @@ -8,7 +8,7 @@ \(\: \:\) false - false + false :( @@ -18,7 +18,7 @@ \:\( \:\( false - false + false \ No newline at end of file diff --git a/license-maven-plugin/src/test/resources/issues/issue-71/issue-71-additionalHeaderDefinitions.xml b/license-maven-plugin/src/test/resources/issues/issue-71/issue-71-additionalHeaderDefinitions.xml index c76355387..5a4ab3117 100644 --- a/license-maven-plugin/src/test/resources/issues/issue-71/issue-71-additionalHeaderDefinitions.xml +++ b/license-maven-plugin/src/test/resources/issues/issue-71/issue-71-additionalHeaderDefinitions.xml @@ -8,7 +8,7 @@ #.* #.* true - false + false false \ No newline at end of file diff --git a/license-maven-plugin/src/test/resources/update/issue37/license-xml-definition.xml b/license-maven-plugin/src/test/resources/update/issue37/license-xml-definition.xml index eddfc05d4..3f1e61a0d 100644 --- a/license-maven-plugin/src/test/resources/update/issue37/license-xml-definition.xml +++ b/license-maven-plugin/src/test/resources/update/issue37/license-xml-definition.xml @@ -7,6 +7,6 @@ (\s|\t)*$]]> false - true + true \ No newline at end of file