diff --git a/README.adoc b/README.adoc index 9a9248f..749e697 100644 --- a/README.adoc +++ b/README.adoc @@ -115,6 +115,7 @@ most of which can also be set on the extension to configure them for all tasks. |dryRun |Show what would happen if the task was run, defaults to false but also inherits from `--dryRun` |skipExistingHeaders |Skip over files that have some header already, which might not be the one specified in the header parameter, defaults to false |useDefaultMappings |Use a long list of standard mapping, defaults to true. See http://code.mycila.com/license-maven-plugin/#supported-comment-types[] for the complete list +|keywords |Specify the list of keywords to use to detect a header. A header must include all keywords to be valid. By default, the word 'copyright' is used. Detection is case insensitive. |strictCheck |Be extra strict in the formatting of existing headers, defaults to false |mapping(String ext, String style) |Adds a mapping between a file extension and a style type |mapping(Map mappings) |Adds mappings between file extensions and style types @@ -137,6 +138,7 @@ most of which can also be set on the extension to configure them for all tasks. |dryRun |Show what would happen if the task was run, defaults to false but also inherits from `--dryRun` |skipExistingHeaders |Skip over files that have some header already, which might not be the one specified in the header parameter, defaults to false |useDefaultMappings |Use a long list of standard mapping, defaults to true. See http://code.mycila.com/license-maven-plugin/#supported-comment-types[] for the complete list +|keywords |Specify the list of keywords to use to detect a header. A header must include all keywords to be valid. By default, the word 'copyright' is used. Detection is case insensitive. |strictCheck |Be extra strict in the formatting of existing headers, defaults to false |mapping(String ext, String style) |Adds a mapping between a file extension and a style type |mapping(Map mappings) |Adds mappings between file extensions and style types @@ -168,6 +170,7 @@ Here is a general overview of the options: |dryRun |Show what would happen if the task was run, defaults to false but also inherits from `--dryRun` |skipExistingHeaders |Skip over files that have some header already, which might not be the one specified in the header parameter, defaults to false |useDefaultMappings |Use a long list of standard mapping, defaults to true. See http://code.mycila.com/license-maven-plugin/#supported-comment-types[] for the complete list +|keywords |Specify the list of keywords to use to detect a header. A header must include all keywords to be valid. By default, the word 'copyright' is used. Detection is case insensitive. |strictCheck |Be extra strict in the formatting of existing headers, defaults to false |mapping(String ext, String style) |Adds a mapping between a file extension and a style type |mapping(Map mappings) |Adds mappings between file extensions and style types diff --git a/src/main/groovy/com/hierynomus/gradle/license/LicenseBasePlugin.groovy b/src/main/groovy/com/hierynomus/gradle/license/LicenseBasePlugin.groovy index f9176f6..6e8cb4e 100644 --- a/src/main/groovy/com/hierynomus/gradle/license/LicenseBasePlugin.groovy +++ b/src/main/groovy/com/hierynomus/gradle/license/LicenseBasePlugin.groovy @@ -76,6 +76,7 @@ class LicenseBasePlugin implements Plugin { dryRun = false skipExistingHeaders = false useDefaultMappings = true + keywords = ['copyright'] strictCheck = false encoding = System.properties['file.encoding'] sourceSets = project.container(SourceSet) @@ -113,6 +114,7 @@ class LicenseBasePlugin implements Plugin { dryRun = { extension.dryRun } skipExistingHeaders = { extension.skipExistingHeaders } useDefaultMappings = { extension.useDefaultMappings } + keywords = { extension.keywords } strictCheck = { extension.strictCheck } inheritedProperties = { extension.ext.properties } inheritedMappings = { extension.internalMappings } diff --git a/src/main/groovy/nl/javadude/gradle/plugins/license/License.groovy b/src/main/groovy/nl/javadude/gradle/plugins/license/License.groovy index d7f0e89..196cdc9 100644 --- a/src/main/groovy/nl/javadude/gradle/plugins/license/License.groovy +++ b/src/main/groovy/nl/javadude/gradle/plugins/license/License.groovy @@ -64,6 +64,12 @@ class License extends SourceTask implements VerificationTask { */ @Input boolean useDefaultMappings + /** + * Specify the list of keywords to use to detect a header. A header must + * include all keywords to be valid. Detection is case insensitive. + */ + @Input Collection keywords; + @Input boolean strictCheck /** @@ -135,7 +141,7 @@ class License extends SourceTask implements VerificationTask { URI uri = resolveURI() - new AbstractLicenseMojo(validHeaders, getProject().rootDir, initial, isDryRun(), isSkipExistingHeaders(), isUseDefaultMappings(), isStrictCheck(), uri, source, combinedMappings, getEncoding(), buildHeaderDefinitions()) + new AbstractLicenseMojo(validHeaders, getProject().rootDir, initial, isDryRun(), isSkipExistingHeaders(), isUseDefaultMappings(), isStrictCheck(), uri, source, combinedMappings, getEncoding(), buildHeaderDefinitions(), getKeywords()) .execute(callback) altered = callback.getAffected() diff --git a/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseExtension.groovy b/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseExtension.groovy index a98b13c..f7c2c79 100644 --- a/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseExtension.groovy +++ b/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseExtension.groovy @@ -72,6 +72,12 @@ class LicenseExtension { */ boolean useDefaultMappings + /** + * Specify the list of keywords to use to detect a header. A header must + * include all keywords to be valid. Detection is case insensitive. + */ + Collection keywords + boolean strictCheck /** diff --git a/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java b/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java index b45b0b6..b092280 100644 --- a/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java +++ b/src/main/groovy/nl/javadude/gradle/plugins/license/maven/AbstractLicenseMojo.java @@ -59,7 +59,7 @@ public class AbstractLicenseMojo { File rootDir; Map initial; - protected String[] keywords = new String[] { "copyright" }; + protected String[] keywords; protected List headerDefinitions; protected HeaderSection[] headerSections = new HeaderSection[0]; protected String encoding; @@ -75,7 +75,8 @@ public class AbstractLicenseMojo { public AbstractLicenseMojo(Collection validHeaders, File rootDir, Map initial, boolean dryRun, boolean skipExistingHeaders, boolean useDefaultMappings, boolean strictCheck, - URI header, FileCollection source, Map mapping, String encoding, List headerDefinitions) { + URI header, FileCollection source, Map mapping, String encoding, List headerDefinitions, + Collection keywords) { this.validHeaders = validHeaders; this.rootDir = rootDir; this.initial = initial; @@ -88,6 +89,7 @@ public AbstractLicenseMojo(Collection validHeaders, File rootDir, Map