From 8f7d930004d739780563aecca4c3c812cab4b432 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Wed, 30 Oct 2024 23:08:15 +0100 Subject: [PATCH] Honor rewrite.resolvePropertiesInYaml flag in classpath scanning (#887) 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. --- .../java/org/openrewrite/maven/AbstractRewriteMojo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java b/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java index 4d80d993..ff9b7347 100644 --- a/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java +++ b/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java @@ -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)); } }