Skip to content

Commit

Permalink
Honor rewrite.resolvePropertiesInYaml flag in classpath scanning (#887)
Browse files Browse the repository at this point in the history
The rewrite.resolvePropertiesInYaml flag introduced in #741
was only applied to the yaml file from the configLocation.

This PR also applies the flag to recipes loaded from the classpath.
  • Loading branch information
jpraet authored Oct 30, 2024
1 parent a309ea0 commit 8f7d930
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ Config getConfig() throws IOException {
}

protected Environment environment(@Nullable ClassLoader recipeClassLoader) throws MojoExecutionException {
Environment.Builder env = Environment.builder(project.getProperties());
Properties propertiesToResolve = resolvePropertiesInYaml ? project.getProperties() : new Properties();
Environment.Builder env = Environment.builder(propertiesToResolve);
if (recipeClassLoader == null) {
env.scanRuntimeClasspath()
.scanUserHome();
} else {
env.load(new ClasspathScanningLoader(project.getProperties(), recipeClassLoader));
env.load(new ClasspathScanningLoader(propertiesToResolve, recipeClassLoader));
}

try {
Config rewriteConfig = getConfig();
if (rewriteConfig != null) {
try (InputStream is = rewriteConfig.inputStream) {
Properties propertiesToResolve = resolvePropertiesInYaml ? project.getProperties() : new Properties();
env.load(new YamlResourceLoader(is, rewriteConfig.uri, propertiesToResolve));
}
}
Expand Down

0 comments on commit 8f7d930

Please sign in to comment.