Repository navigation
|
Hi, I am currently writing a custom Recipe and have generated a @Override
public void defaults(RecipeSpec spec) {
spec
.recipeFromResource("/META-INF/rewrite/tupstdmid-log.yml", "tup.std.rewrite.log.refactor_7_1")
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "tupstdmid-log-api"));
}Is something like this also required once the rewriter is executed in production mode? Or will all classes from |
Replies: 1 comment 6 replies
|
hi! When you use JavaTemplate, or when you provide test text blocks, those are snippets get compiled in complete isolation from your project classpath. This is to allow multiple major versions of libraries to be used within a single recipe module, but does then indeed require that you construct a JavaParser, and provide it with the entries it should place on the classpath (and any imports) when you compile the provided snippets. For your tests the above pattern already looks correct to me (maybe add a version suffix such as Hope that helps you there! |
hi! When you use JavaTemplate, or when you provide test text blocks, those are snippets get compiled in complete isolation from your project classpath. This is to allow multiple major versions of libraries to be used within a single recipe module, but does then indeed require that you construct a JavaParser, and provide it with the entries it should place on the classpath (and any imports) when you compile the provided snippets.
For your tests the above pattern already looks correct to me (maybe add a version suffix such as
tupstdmid-log-api-1); for your main code you'll similarly want to useclasspathFromResourcesbut provide it with the ExecutionContext instance that's already passed in…