目前我开发了自己的插件,它将通过加载影响资源过滤的其他文件来进行资源过滤。
我的插件(执行)方法中包含以下代码:
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);
}
}
但在我的集成测试期间,过滤将不会完成。在我的输出中,我找不到getValue(),getFeedback()等的输出。
目前,我的集成测试期间的输出如下:
[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
但不幸的是,在这种情况下不会调用getValue()方法。
所以问题是:有人知道我做错了什么吗? (完整来源可用here。
答案 0 :(得分:0)
解决方案不是使用正则表达式:
mavenResourcesExecution.addFilerWrapperWithEscaping(valueSource, "@", "@", "@", false);