diff --git a/README.md b/README.md new file mode 100644 index 0000000..cdc90ed --- /dev/null +++ b/README.md @@ -0,0 +1,184 @@ + +# Regular Expression Maven Plugin + +This is a maven plugin that provides various regular expression based goals to Maven. + +## Usage + +```xml + + ... + + ... + + ... + + com.inteligr8 + regex-maven-plugin + ... + + + sample-regex-test + validate + replace-property + + a.property.to.eval + + + \.txt + + + + a.new.property.to.set + + + + + ... + + ... + + ... + +``` + +## Goals + +| Goal | Description | +| -------------------- | ----------- | +| `replace-file` | Apply a regular expression pattern against the contents of a file, replacing matches with the specified text. The existing file is changed. | +| `replace-properties` | Apply a regular expression pattern against a set of property values, replacing matches with the specified text, and storing in new properties. | +| `replace-property` | Apply a regular expression pattern against a property value, replacing matches with the specified text, and storing in a new property. | +| `replace-text` | Apply a regular expression pattern against text, replacing matches with the specified text, and storing in a new property. | +| `match-file` | Evaluate a regular expression pattern against the contents of a file, storing the result in a boolean property. | +| `match-filename` | Evaluate a regular expression pattern against the name of a file, storing the result in a boolean property. | +| `match-properties` | Evaluate a regular expression pattern against a set of property values, storing the result in boolean properties. | +| `match-property` | Evaluate a regular expression pattern against a property value, storing the result in a boolean property. | +| `match-text` | Evaluate a regular expression pattern against text, storing the result in a boolean property. | +| `copy-file` | A convenience goal that copies all files/folders specified in a source path to a target path. | +| `move-file` | A convenience goal that moves all files/folders specified in a source path to a target path. | + +### Goal: `replace-file` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:-----------:|:--------:| ------- | ----------- | +| `chunkSize` | `int` | | `1024` | The streaming buffer/chunk size in bytes, while evaluating the regular expressions. Adjust for classic speed/memory trade-off. Be aware that files are processed line-by-line, unless `allowMultiLineMatch` is set to `true`. | +| `filesets` | `FileSet[]` | Yes | | Executes against these files. | +| `regexes` | `Regex[]` | Yes | | Applies these regular expressions and replacement text against those files. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. This takes substantially more memory/time to process. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `replace-properties` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| -------- | ----------- | +| `properties` | `String[]` | Yes | | Executes against these properties. | +| `newPropertySuffix` | `String` | | `-regex` | All evaluated properties will be copied to new properties with the same property name plus this suffix. | +| `regexes` | `Regex[]` | Yes | | Applies these regular expressions and replacement text against those files. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. This takes substantially more memory/time to process. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `replace-property` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| ------- | ----------- | +| `property` | `String` | Yes | | Executes against this property. | +| `newProperty` | `String` | | | The evaluated property will be copied to this property name. If not specified, it will be the same name as the `property` with a `-regex` suffix. | +| `regexes` | `Regex[]` | Yes | | Applies these regular expressions and replacement text against those files. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. This takes substantially more memory/time to process. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `replace-text` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| ------- | ----------- | +| `text` | `String` | Yes | | Execute against this text. | +| `newProperty` | `String` | Yes | | The evaluated text will be copied to this property name. | +| `regexes` | `Regex[]` | Yes | | Applies these regular expressions and replacement text against those files. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. This takes substantially more memory/time to process. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `match-file` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:-----------:|:--------:| ------- | ----------- | +| `chunkSize` | `int` | | `1024` | The streaming buffer/chunk size in bytes, while evaluating the regular expressions. Adjust for classic speed/memory trade-off. Be aware that files are processed line-by-line, unless `allowMultiLineMatch` is set to `true`. | +| `filesets` | `FileSet[]` | Yes | | Executes against these files. | +| `newProperty` | `String` | Yes | | If a single regular expression matches the contents in a single file, then this property will be set to `true`; `false` otherwise. | +| `patterns` | `String[]` | Yes | | Evaluates these regular expressions against those files. | +| `allowPartialMatch` | `boolean` | | `true` | A value of `true` allows for partial matching, rather than exact line-by-line matching. | +| `negate` | `boolean` | | `false` | A value of `true` will reverse the `true`/`false` on the resultant property value. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. This takes substantially more memory/time to process. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `match-filename` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:-----------:|:--------:| ------- | ----------- | +| `sourceDirectory` | `File` | Yes | | Executes against this file. | +| `newProperty` | `String` | Yes | | If a single regular expression matches the name of the file, then this property will be set to `true`; `false` otherwise. | +| `patterns` | `String[]` | Yes | | Evaluates these regular expressions the file. | +| `allowPartialMatch` | `boolean` | | `true` | A value of `true` allows for partial matching, rather than exact filename matching. | +| `negate` | `boolean` | | `false` | A value of `true` will reverse the `true`/`false` on the resultant property value. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `match-properties` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| -------- | ----------- | +| `properties` | `String[]` | Yes | | Executes against these properties. | +| `newPropertySuffix` | `String` | | `-regex` | All evaluated properties will be copied to new properties with the same property name plus this suffix. | +| `patterns` | `String[]` | Yes | | Evaluates these regular expressions against those properties' values. | +| `allowPartialMatch` | `boolean` | | `true` | A value of `true` allows for partial matching, rather than exact matching. | +| `negate` | `boolean` | | `false` | A value of `true` will reverse the `true`/`false` on the resultant property value. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. Very rare for property evaluation. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `match-property` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| ------- | ----------- | +| `property` | `String` | Yes | | Executes against this property. | +| `newProperty` | `String` | | | The evaluated property will be copied to this property name. If not specified, it will be the same name as the `property` with a `-regex` suffix. | +| `patterns` | `String[]` | Yes | | Evaluates these regular expressions against the property value. | +| `allowPartialMatch` | `boolean` | | `true` | A value of `true` allows for partial matching, rather than exact matching. | +| `negate` | `boolean` | | `false` | A value of `true` will reverse the `true`/`false` on the resultant property value. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. Very rare for property evaluation. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `match-text` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| ------- | ----------- | +| `text` | `String` | Yes | | Execute against this text. | +| `newProperty` | `String` | Yes | | The evaluated text will be copied to this property name. | +| `patterns` | `String[]` | Yes | | Evaluates these regular expressions against the property value. | +| `allowPartialMatch` | `boolean` | | `true` | A value of `true` allows for partial matching, rather than exact matching. | +| `negate` | `boolean` | | `false` | A value of `true` will reverse the `true`/`false` on the resultant property value. | +| `allowMultiLineMatch` | `boolean` | | `false` | A value of `true` allows for multi-line matching. Very rare for property evaluation. | +| `charset` | `string` | | `utf-8` | | +| `skip` | `boolean` | | `false` | | + +### Goal: `copy-file` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| --------- | ----------- | +| `sourceDirectory` | `File` | | ${basedir} | Copy all files from this directory. | +| `targetDirectory` | `File` | | ${basedir} | Copy all files to this directory. | +| `overwrite` | `boolean` | | `true` | | + +### Goal: `move-file` + +| Configuration Property | Data Type | Required | Default | Description | +| ---------------------- |:----------:|:--------:| --------- | ----------- | +| `sourceDirectory` | `File` | | ${basedir} | Move all files from this directory. | +| `targetDirectory` | `File` | | ${basedir} | Move all files to this directory. | +| `overwrite` | `boolean` | | `true` | | diff --git a/pom.xml b/pom.xml index a8144ce..2b3f260 100644 --- a/pom.xml +++ b/pom.xml @@ -10,9 +10,20 @@ 1.0-SNAPSHOT maven-plugin - A Maven plugin for regex operations + Regular Expression Maven Plugin + A Maven plugin for regular expression operations + https://bitbucket.org/inteligr8/regex-maven-plugin + + + + GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007 + https://www.gnu.org/licenses/lgpl-3.0.txt + + + scm:git:https://bitbucket.org/inteligr8/regex-maven-plugin.git + scm:git:git@bitbucket.org:inteligr8/regex-maven-plugin.git https://bitbucket.org/inteligr8/regex-maven-plugin @@ -142,19 +153,6 @@ - - maven-javadoc-plugin - - - javadoc - package - jar - - public - - - - @@ -189,14 +187,57 @@ + + ossrh-release + + + + maven-source-plugin + + + source + package + jar-no-fork + + + + + maven-javadoc-plugin + + + javadoc + package + jar + + public + + + + + + maven-gpg-plugin + + + sign + verify + sign + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + + - - - inteligr8-releases - Inteligr8 Releases - http://repos.inteligr8.com/nexus/repository/inteligr8-public - - - diff --git a/src/main/java/com/inteligr8/maven/regex/ReplaceTextMojo.java b/src/main/java/com/inteligr8/maven/regex/ReplaceTextMojo.java index b4d2b4b..60e50c4 100644 --- a/src/main/java/com/inteligr8/maven/regex/ReplaceTextMojo.java +++ b/src/main/java/com/inteligr8/maven/regex/ReplaceTextMojo.java @@ -28,7 +28,7 @@ public class ReplaceTextMojo extends AbstractReplaceMojo { @Parameter( property = "text", required = true ) protected String text; - @Parameter( property = "newProperty", required = false ) + @Parameter( property = "newProperty", required = true ) protected String newProperty; @Override