The solution is NOT to use regular expressions:
mavenResourcesExecution.addFilerWrapperWithEscaping(valueSource, "@", "@", "@", false);
Domanda
Currently i develop my own plugin which will do resource filtering with loading of a an other file which influence the resource filtering.
I have the following code in my plugin (execute) method:
public void execute() throws MojoExecutionException {
if (StringUtils.isEmpty(encoding) && isFilteringEnabled(getResources())) {
getLog().warn(
"File encoding has not been set, using platform encoding "
+ ReaderFactory.FILE_ENCODING
+ ", i.e. build is platform dependent!");
}
Scope scope = convertToScope(getScope());
getLog().info("Hallo welt. (" + scope + ")");
if (getResources() != null) {
for (Resource item : getResources()) {
getLog().info(" --| Resource: " + item.getFiltering() + "|" + item.getDirectory());
}
}
try {
MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(
resources, outputDirectory, project, encoding, null,
nonFilteredFileExtensions, mavenSession);
ValueSource valueSource = new ValueSource() {
@Override
public Object getValue(String expression) {
getLog().info("Expression: " + expression);
return "XXX";
}
@Override
public List getFeedback() {
getLog().info("getFeedback()");
return Collections.EMPTY_LIST;
}
@Override
public void clearFeedback() {
// TODO Auto-generated method stub
getLog().info("clearFeedback()");
}
};
mavenResourcesExecution.addFilerWrapperWithEscaping(valueSource,
"\\@", "\\@", "@", false);
mavenResourcesExecution.setUseDefaultFilterWrappers(false);
mavenResourcesFiltering.filterResources(mavenResourcesExecution);
} catch (MavenFilteringException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
But during my integration tests the filtering will not be done. In my output i can't find the output of getValue(), getFeedback() etc.
Currently the output during my integration test looks like:
[INFO] Hallo welt. ()
[INFO] --| Resource: true|src/main/resource-files
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[DEBUG] resource with targetPath null
directory src/main/resource-files
excludes []
includes []
[DEBUG] ignoreDelta true
[INFO] Copying 1 resource
[DEBUG] file thisIsTheFirst.properties has a filtered file extension
[DEBUG] filtering ..it\configurationTest\src\main\resource-files\thisIsTheFirst.properties to ...\it\configurationTest\target\classes\thisIsTheFirst.properties
But unfortunately the getValue() method is not called in this case.
So the question is: Does someone has an idea what i'm doing wrong ? (Full source is available here.
Soluzione
The solution is NOT to use regular expressions:
mavenResourcesExecution.addFilerWrapperWithEscaping(valueSource, "@", "@", "@", false);