Skip to content

Commit 03c1a2e

Browse files
committed
fix: Fix Removal of redundant compiler plugins
1 parent 42d53d0 commit 03c1a2e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/cleanup/actions/RemoveRedundantMavenCompilerPluginProperties.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
import java.util.Optional;
1919

20+
import lombok.extern.slf4j.Slf4j;
2021
import org.springframework.sbm.build.api.Module;
2122
import org.springframework.sbm.engine.context.ProjectContext;
2223
import org.springframework.sbm.engine.recipe.AbstractAction;
2324

25+
@Slf4j
2426
public class RemoveRedundantMavenCompilerPluginProperties extends AbstractAction {
2527

2628
private static final String GROUP_ID = "org.apache.maven.plugins";
@@ -51,8 +53,8 @@ public void apply(ProjectContext context) {
5153

5254
if (sourceLookupValue.equals(targetLookupValue)) {
5355
buildFile.setProperty(JAVA_VERSION_PROPERTY, sourceLookupValue);
54-
plugin.getConfiguration().setDeclaredStringValue("source", JAVA_VERSION_PLACEHOLDER);
55-
plugin.getConfiguration().setDeclaredStringValue("target", JAVA_VERSION_PLACEHOLDER);
56+
buildFile.findPlugin(GROUP_ID, ARTIFACT_ID).get().getConfiguration().setDeclaredStringValue("source", JAVA_VERSION_PLACEHOLDER);
57+
buildFile.findPlugin(GROUP_ID, ARTIFACT_ID).get().getConfiguration().setDeclaredStringValue("target", JAVA_VERSION_PLACEHOLDER);
5658
if(source.get().startsWith("${")){
5759
buildFile.deleteProperty(source.get().replace("${", "").replace("}", ""));
5860
}
@@ -63,11 +65,12 @@ public void apply(ProjectContext context) {
6365

6466
}
6567

66-
}); //Plugin exits
68+
}); //Plugin exists
6769

6870
String sourcePropertyValue = buildFile.getProperty(MAVEN_COMPILER_SOURCE_PROPERTY);
6971
String targetPropertyValue = buildFile.getProperty(MAVEN_COMPILER_TARGET_PROPERTY);
70-
72+
log.debug("BuildFile: '%s'\n%s".formatted(buildFile.getSourcePath().toString(), buildFile.print()));
73+
log.debug("%s: %s %s: %s".formatted(MAVEN_COMPILER_SOURCE_PROPERTY, sourcePropertyValue, MAVEN_COMPILER_TARGET_PROPERTY, targetPropertyValue));
7174
if (sourcePropertyValue != null && sourcePropertyValue.equals(targetPropertyValue)){
7275
buildFile.setProperty(JAVA_VERSION_PROPERTY, sourcePropertyValue);
7376
buildFile.deleteProperty(MAVEN_COMPILER_SOURCE_PROPERTY);

0 commit comments

Comments
 (0)