You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "jlahoda (via GitHub)" <gi...@apache.org> on 2023/04/17 21:05:39 UTC

[GitHub] [netbeans] jlahoda commented on a diff in pull request #5802: Improving enable-preview Java fix

jlahoda commented on code in PR #5802:
URL: https://github.com/apache/netbeans/pull/5802#discussion_r1169266423


##########
java/maven.hints/src/org/netbeans/modules/maven/hints/errors/EnablePreviewMavenProj.java:
##########
@@ -245,18 +182,36 @@ private Configuration createConfiguration() {
         }
 
         private Plugin updateMavenCompilerPlugin(final Plugin oldPlugin) {
-
             Configuration currenConfig = oldPlugin.getConfiguration();
+            Plugin newPlugin = factory.createPlugin();
+            newPlugin.setGroupId(oldPlugin.getGroupId());
+            newPlugin.setArtifactId(oldPlugin.getArtifactId());
+            newPlugin.setVersion(oldPlugin.getVersion());
+            newPlugin.setConfiguration(updateMavenCompilerPluginConfiguration(currenConfig));
+            return newPlugin;
+        }
+
+        private Configuration updateMavenCompilerPluginConfiguration(final Configuration currenConfig) {
             Configuration newConfiguration = createConfiguration();
 
-            boolean isCompilerArgsElementPresent = false;
             if (currenConfig != null) {
+                boolean isCompilerArgsElementPresent = false;
+                boolean isSourceElementPresent = false;
+                boolean isTargetElementPresent = false;
                 for (POMExtensibilityElement element : currenConfig.getConfigurationElements()) {
                     POMExtensibilityElement newElement = factory.createPOMExtensibilityElement(element.getQName());
                     String elementText = element.getElementText();
                     if (elementText.trim().length() > 0) {
                         newElement.setElementText(element.getElementText());
                     }
+                    if (newElement.getQName().getLocalPart().equals(SOURCE) && newSourceLevel != null) {
+                        newElement.setElementText(newSourceLevel);
+                        isSourceElementPresent = true;
+                    }
+                    if (newElement.getQName().getLocalPart().equals(TARGET) && newSourceLevel != null) {
+                        newElement.setElementText(newSourceLevel);
+                        isTargetElementPresent = true;
+                    }

Review Comment:
   Given the needed tweaks for the pom.xml provider, I guess we can wait with this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists