17
17
18
18
import java .util .Optional ;
19
19
20
+ import lombok .extern .slf4j .Slf4j ;
20
21
import org .springframework .sbm .build .api .Module ;
21
22
import org .springframework .sbm .engine .context .ProjectContext ;
22
23
import org .springframework .sbm .engine .recipe .AbstractAction ;
23
24
25
+ @ Slf4j
24
26
public class RemoveRedundantMavenCompilerPluginProperties extends AbstractAction {
25
27
26
28
private static final String GROUP_ID = "org.apache.maven.plugins" ;
@@ -51,8 +53,8 @@ public void apply(ProjectContext context) {
51
53
52
54
if (sourceLookupValue .equals (targetLookupValue )) {
53
55
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 );
56
58
if (source .get ().startsWith ("${" )){
57
59
buildFile .deleteProperty (source .get ().replace ("${" , "" ).replace ("}" , "" ));
58
60
}
@@ -63,11 +65,12 @@ public void apply(ProjectContext context) {
63
65
64
66
}
65
67
66
- }); //Plugin exits
68
+ }); //Plugin exists
67
69
68
70
String sourcePropertyValue = buildFile .getProperty (MAVEN_COMPILER_SOURCE_PROPERTY );
69
71
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 ));
71
74
if (sourcePropertyValue != null && sourcePropertyValue .equals (targetPropertyValue )){
72
75
buildFile .setProperty (JAVA_VERSION_PROPERTY , sourcePropertyValue );
73
76
buildFile .deleteProperty (MAVEN_COMPILER_SOURCE_PROPERTY );
0 commit comments