-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to add custom header definitions (#132)
- Loading branch information
1 parent
a0ed859
commit 0e6514c
Showing
9 changed files
with
367 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/main/groovy/nl/javadude/gradle/plugins/license/header/HeaderDefinitionBuilder.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package nl.javadude.gradle.plugins.license.header | ||
|
||
import com.google.code.mojo.license.header.HeaderDefinition | ||
import org.gradle.api.Named | ||
|
||
class HeaderDefinitionBuilder implements Named { | ||
String type | ||
String firstLine | ||
String beforeEachLine | ||
String endLine | ||
boolean allowBlankLines = false | ||
|
||
String skipLinePattern | ||
String firstLineDetectionPattern | ||
String lastLineDetectionPattern | ||
boolean isMultiline = false | ||
|
||
static HeaderDefinitionBuilder headerDefinition(String name) { | ||
return new HeaderDefinitionBuilder(name) | ||
} | ||
|
||
HeaderDefinitionBuilder(String type) { | ||
this.type = type | ||
} | ||
|
||
HeaderDefinitionBuilder withFirstLine(String firstLine) { | ||
this.firstLine = firstLine | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder withBeforeEachLine(String beforeEachLine) { | ||
this.beforeEachLine = beforeEachLine | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder withEndLine(String endLine) { | ||
this.endLine = endLine | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder withNoBlankLines() { | ||
this.allowBlankLines = false | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder withBlankLines() { | ||
this.allowBlankLines = true | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder withSkipLinePattern(String skipLinePattern) { | ||
this.skipLinePattern = skipLinePattern | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder withFirstLineDetectionDetectionPattern(String firstLineDetectionPattern) { | ||
this.firstLineDetectionPattern = firstLineDetectionPattern | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder withLastLineDetectionDetectionPattern(String lastLineDetectionPattern) { | ||
this.lastLineDetectionPattern = lastLineDetectionPattern | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder multiline() { | ||
this.isMultiline = true | ||
return this | ||
} | ||
|
||
HeaderDefinitionBuilder noMultiLine() { | ||
this.isMultiline = false | ||
return this | ||
} | ||
|
||
HeaderDefinition build() { | ||
return new HeaderDefinition(type, | ||
firstLine, | ||
beforeEachLine, | ||
endLine, | ||
skipLinePattern, | ||
firstLineDetectionPattern, | ||
lastLineDetectionPattern, | ||
allowBlankLines, | ||
isMultiline) | ||
} | ||
|
||
@Override | ||
String toString() { | ||
return "{" + | ||
"type='" + type + '\'' + | ||
", firstLine='" + firstLine + '\'' + | ||
", beforeEachLine='" + beforeEachLine + '\'' + | ||
", endLine='" + endLine + '\'' + | ||
", allowBlankLines=" + allowBlankLines + | ||
", skipLinePattern='" + skipLinePattern + '\'' + | ||
", firstLineDetectionPattern='" + firstLineDetectionPattern + '\'' + | ||
", lastLineDetectionPattern='" + lastLineDetectionPattern + '\'' + | ||
", isMultiline=" + isMultiline + | ||
'}' | ||
} | ||
|
||
@Override | ||
String getName() { | ||
return type | ||
} | ||
} |
Oops, something went wrong.