fixed regex trim

This commit is contained in:
Brian Long 2021-06-03 19:58:44 -04:00
parent 934de5da82
commit 050742bcf7
3 changed files with 15 additions and 7 deletions

View File

@ -14,8 +14,6 @@
*/ */
package com.inteligr8.maven.model; package com.inteligr8.maven.model;
import org.apache.commons.lang3.StringUtils;
public class Regex implements Normalizable { public class Regex implements Normalizable {
private String pattern; private String pattern;
@ -41,8 +39,7 @@ public class Regex implements Normalizable {
@Override @Override
public void normalize() { public void normalize() {
this.pattern = StringUtils.trimToNull(this.pattern); // do not trim
this.replacement = StringUtils.trimToNull(this.replacement);
} }
} }

View File

@ -89,10 +89,23 @@ public class MatchFileContentMojo extends AbstractMatchMojo {
return path; return path;
} }
@Override
protected void validateParamsPreNormalization() throws MojoFailureException {
super.validateParamsPreNormalization();
if (this.filesets == null || this.filesets.isEmpty())
throw new MojoFailureException("At least one 'fileset' is required");
}
@Override @Override
protected void normalizeParameters() throws MojoFailureException { protected void normalizeParameters() throws MojoFailureException {
super.normalizeParameters(); super.normalizeParameters();
for (FileSet fileset : this.filesets) {
if (fileset.getDirectory() == null)
fileset.setDirectory(this.project.getBasedir().getAbsolutePath());
}
this.newProperty = StringUtils.trimToNull(this.newProperty); this.newProperty = StringUtils.trimToNull(this.newProperty);
} }
@ -100,8 +113,6 @@ public class MatchFileContentMojo extends AbstractMatchMojo {
protected void validateParamsPostNormalization() throws MojoFailureException { protected void validateParamsPostNormalization() throws MojoFailureException {
super.validateParamsPostNormalization(); super.validateParamsPostNormalization();
if (this.filesets == null || this.filesets.isEmpty())
throw new MojoFailureException("At least one 'fileset' is required");
if (this.newProperty == null) if (this.newProperty == null)
throw new MojoFailureException("The 'newProperty' element is required"); throw new MojoFailureException("The 'newProperty' element is required");
} }

View File

@ -111,7 +111,7 @@ public class ReplaceFileContentMojo extends AbstractReplaceMojo {
if (fileset.getDirectory() == null) if (fileset.getDirectory() == null)
fileset.setDirectory(this.project.getBasedir().getAbsolutePath()); fileset.setDirectory(this.project.getBasedir().getAbsolutePath());
if (fileset.getOutputDirectory() == null) if (fileset.getOutputDirectory() == null)
fileset.setOutputDirectory(this.project.getBasedir().getAbsolutePath()); fileset.setOutputDirectory(fileset.getDirectory());
} }
} }