Skip to content

Commit

Permalink
Merge pull request #247 from mathieucarbou/multiline
Browse files Browse the repository at this point in the history
Correctly fix the multiLine tag
  • Loading branch information
mathieucarbou authored Nov 26, 2021
2 parents d0f387f + 42e024e commit 06b4bad
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 32 deletions.
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ In license-maven-plugin, each header style is defined by patterns to detect it a
<firstLineDetectionPattern>(\s|\t)*/\*.*$</firstLineDetectionPattern>
<lastLineDetectionPattern>.*\*/(\s|\t)*$</lastLineDetectionPattern>
<allowBlankLines>false</allowBlankLines>
<isMultiline>true</isMultiline>
<multiLine>true</multiLine>
<padLines>false</padLines>
</javadoc_style>
</additionalHeaders>
Expand All @@ -565,7 +565,7 @@ And for XML:
<firstLineDetectionPattern><![CDATA[(\s|\t)*<!--.*$]]></firstLineDetectionPattern>
<lastLineDetectionPattern><![CDATA[.*-->(\s|\t)*$]]></lastLineDetectionPattern>
<allowBlankLines>false</allowBlankLines>
<isMultiline>true</isMultiline>
<multiLine>true</multiLine>
<padLines>false</padLines>
</xml_style>
</additionalHeaders>
Expand All @@ -587,15 +587,15 @@ This page will show you how you can define extended header definitions to fit yo
<firstLineDetectionPattern>#region.*^EOL/\*\*.*$</firstLineDetectionPattern>
<lastLineDetectionPattern>\*/EOL#endregion"</lastLineDetectionPattern>
<allowBlankLines>true</allowBlankLines>
<isMultiline>true</isMultiline>
<multiLine>true</multiLine>
</csregion_style>
</additionalHeaders>
```

* 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 <!-- and before --> 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:

Expand Down Expand Up @@ -658,7 +658,7 @@ The following example will redefine the header file for text files:
<firstLineDetectionPattern>\:\(</firstLineDetectionPattern>
<lastLineDetectionPattern>\:\(</lastLineDetectionPattern>
<allowBlankLines>false</allowBlankLines>
<multiline>false</multiline>
<multiLine>false</multiLine>
</defaultInlineHeaderStyle>
</defaultInlineHeaderStyles>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licensePluginReport goal="CHECK" timestamp="1637930352734">
<licensePluginReport goal="CHECK" timestamp="1637933147719">
<module artifactId="license-maven-plugin-git" groupId="com.mycila" version="4.2-SNAPSHOT"/>
<files>
<file path="pom.xml" result="PRESENT"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licensePluginReport goal="CHECK" timestamp="1637930359613">
<licensePluginReport goal="CHECK" timestamp="1637933148049">
<module artifactId="license-maven-plugin-svn" groupId="com.mycila" version="4.2-SNAPSHOT"/>
<files>
<file path="README.MD" result="UNKNOWN"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licensePluginReport goal="CHECK" timestamp="1637930343672">
<licensePluginReport goal="CHECK" timestamp="1637933145472">
<module artifactId="license-maven-plugin" groupId="com.mycila" version="4.2-SNAPSHOT"/>
<files>
<file path="pom.xml" result="PRESENT"/>
Expand Down
2 changes: 1 addition & 1 deletion docs/reports/4.2-SNAPSHOT/license-plugin-report.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licensePluginReport goal="CHECK" timestamp="1637930301487">
<licensePluginReport goal="CHECK" timestamp="1637933111579">
<module artifactId="license-maven-plugin-parent" groupId="com.mycila" version="4.2-SNAPSHOT"/>
<files>
<file path="pom.xml" result="PRESENT"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public class HeaderStyle {
* <p>
* 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.
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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");
}
}

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -256,6 +256,6 @@ public String toString() {
}

public boolean isMultiLine() {
return isMultiline;
return multiLine;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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());

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<firstLineDetectionPattern>\(\:</firstLineDetectionPattern>
<lastLineDetectionPattern>\:\)</lastLineDetectionPattern>
<allowBlankLines>false</allowBlankLines>
<isMultiline>false</isMultiline>
<multiLine>false</multiLine>
</smiley>
<text>
<firstLine>:(</firstLine>
Expand All @@ -18,7 +18,7 @@
<firstLineDetectionPattern>\:\(</firstLineDetectionPattern>
<lastLineDetectionPattern>\:\(</lastLineDetectionPattern>
<allowBlankLines>false</allowBlankLines>
<isMultiline>false</isMultiline>
<multiLine>false</multiLine>
</text>
</additionalHeaders>

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<firstLineDetectionPattern>#.*</firstLineDetectionPattern>
<lastLineDetectionPattern>#.*</lastLineDetectionPattern>
<allowBlankLines>true</allowBlankLines>
<isMultiline>false</isMultiline>
<multiLine>false</multiLine>
<padLines>false</padLines>
</extended_style>
</additionalHeaders>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<firstLineDetectionPattern><![CDATA[(\s|\t)*<!--.*$]]></firstLineDetectionPattern>
<lastLineDetectionPattern><![CDATA[.*-->(\s|\t)*$]]></lastLineDetectionPattern>
<allowBlankLines>false</allowBlankLines>
<isMultiline>true</isMultiline>
<multiLine>true</multiLine>
</xml_style>
</additionalHeaders>

0 comments on commit 06b4bad

Please sign in to comment.