我正在创建一个根据特定条件修改最终JAVA项目的方法。
用例将是:
这看起来很简单,但我无法让任何访问者处理具有*.test扩展名的文件。
例如,我尝试了以下几种方法:
static class MarkerRecipe extends Recipe {
@Override
public String getDisplayName() {
return "arker Recipe";
}
@Override
protected TreeVisitor<?, ExecutionContext> getSingleSourceApplicableTest() {
return new HasSourcePath<>("**/*.test");
}
@Override
protected PlainTextVisitor<ExecutionContext> getVisitor() {
return new PlainTextVisitor<ExecutionContext>() {
@Override
public @Nullable PlainText postVisit(final PlainText tree, final ExecutionContext executionContext) {
if (tree.getSourcePath().toString().endsWith("file.test")) {
// Add maven Property
MarkerRecipe.this.doNext(new ChangePropertyValue("maven-property", "to fill!", true));
}
return super.postVisit(tree, executionContext);
}
};
}
}我还尝试使用org.openrewrite.FindSourceFiles菜谱,如下所示:将它添加到princpipal菜谱并进行调试,以查看它是否检测到*.test文件类型:
this.doNext(new FindSourceFiles("*.test"));我在src/main/java,src/main/resources,src/main/files中都创建了src/main/resources文件,但是没有什么工作.
知道吗?
我使用的是开放重写7.22.0
https://stackoverflow.com/questions/72188993
复制相似问题