You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "khmarbaise (via GitHub)" <gi...@apache.org> on 2023/04/13 18:39:29 UTC

[GitHub] [maven] khmarbaise opened a new pull request, #1088: [MNG-7764] - Small Code Improvments.

khmarbaise opened a new pull request, #1088:
URL: https://github.com/apache/maven/pull/1088

   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed
          for the change (usually before you start working on it).  Trivial changes like typos do not
          require a JIRA issue. Your pull request should address just this issue, without
          pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[MNG-XXX] SUMMARY`,
          where you replace `MNG-XXX` and `SUMMARY` with the appropriate JIRA issue.
    - [ ] Also format the first line of the commit message like `[MNG-XXX] SUMMARY`.
          Best practice is to use the JIRA issue title in both the pull request title and in the first line of the commit message.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
          be performed on your pull request automatically.
    - [ ] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven] gnodet merged pull request #1088: [MNG-7764] Small code improvements

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #1088:
URL: https://github.com/apache/maven/pull/1088


-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven] gnodet commented on a diff in pull request #1088: [MNG-7764] - Small Code Improvments.

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1088:
URL: https://github.com/apache/maven/pull/1088#discussion_r1166498043


##########
maven-core/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java:
##########
@@ -55,23 +54,17 @@ public DefaultToolchainsBuilder(org.apache.maven.toolchain.building.ToolchainsBu
     @Override
     public ToolchainsBuilderResult build(ToolchainsBuilderRequest request)
             throws ToolchainsBuilderException, IllegalArgumentException {
-        DefaultSession session = (DefaultSession) request.getSession();
         try {
             DefaultToolchainsBuildingRequest req = new DefaultToolchainsBuildingRequest();
-            if (request.getGlobalToolchainsSource().isPresent()) {
-                req.setGlobalToolchainsSource(new MappedToolchainsSource(
-                        request.getGlobalToolchainsSource().get()));
-            } else if (request.getGlobalToolchainsPath().isPresent()) {
-                req.setGlobalToolchainsSource(new org.apache.maven.building.FileSource(
-                        request.getGlobalToolchainsPath().get().toFile()));
-            }
-            if (request.getUserToolchainsSource().isPresent()) {
-                req.setUserToolchainsSource(new MappedToolchainsSource(
-                        request.getUserToolchainsSource().get()));
-            } else if (request.getUserToolchainsPath().isPresent()) {
-                req.setUserToolchainsSource(new org.apache.maven.building.FileSource(
-                        request.getUserToolchainsPath().get().toFile()));
-            }
+
+            request.getGlobalToolchainsSource()
+                    .ifPresent(s -> req.setGlobalToolchainsSource(new MappedToolchainsSource(s)));
+            request.getGlobalToolchainsPath().ifPresent(s -> req.setGlobalToolchainsSource(new FileSource(s.toFile())));

Review Comment:
   Not sure if this is problematic, but the before and after code are not equivalent.
   In the code before, the `setGlobalToolchainsSource` cannot be called twice because of the `else if` statement.  With the new proposed code, a second call will override the first one...



##########
maven-core/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java:
##########
@@ -55,23 +54,17 @@ public DefaultToolchainsBuilder(org.apache.maven.toolchain.building.ToolchainsBu
     @Override
     public ToolchainsBuilderResult build(ToolchainsBuilderRequest request)
             throws ToolchainsBuilderException, IllegalArgumentException {
-        DefaultSession session = (DefaultSession) request.getSession();
         try {
             DefaultToolchainsBuildingRequest req = new DefaultToolchainsBuildingRequest();
-            if (request.getGlobalToolchainsSource().isPresent()) {
-                req.setGlobalToolchainsSource(new MappedToolchainsSource(
-                        request.getGlobalToolchainsSource().get()));
-            } else if (request.getGlobalToolchainsPath().isPresent()) {
-                req.setGlobalToolchainsSource(new org.apache.maven.building.FileSource(
-                        request.getGlobalToolchainsPath().get().toFile()));
-            }
-            if (request.getUserToolchainsSource().isPresent()) {
-                req.setUserToolchainsSource(new MappedToolchainsSource(
-                        request.getUserToolchainsSource().get()));
-            } else if (request.getUserToolchainsPath().isPresent()) {
-                req.setUserToolchainsSource(new org.apache.maven.building.FileSource(
-                        request.getUserToolchainsPath().get().toFile()));
-            }
+
+            request.getGlobalToolchainsSource()
+                    .ifPresent(s -> req.setGlobalToolchainsSource(new MappedToolchainsSource(s)));
+            request.getGlobalToolchainsPath().ifPresent(s -> req.setGlobalToolchainsSource(new FileSource(s.toFile())));
+
+            request.getUserToolchainsSource()
+                    .ifPresent(s -> req.setUserToolchainsSource(new MappedToolchainsSource(s)));
+            request.getUserToolchainsPath().ifPresent(s -> req.setUserToolchainsSource(new FileSource(s.toFile())));

Review Comment:
   Same here



-- 
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: issues-unsubscribe@maven.apache.org

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


[GitHub] [maven] khmarbaise commented on a diff in pull request #1088: [MNG-7764] - Small Code Improvments.

Posted by "khmarbaise (via GitHub)" <gi...@apache.org>.
khmarbaise commented on code in PR #1088:
URL: https://github.com/apache/maven/pull/1088#discussion_r1167483332


##########
maven-core/src/main/java/org/apache/maven/internal/impl/DefaultToolchainsBuilder.java:
##########
@@ -55,23 +54,17 @@ public DefaultToolchainsBuilder(org.apache.maven.toolchain.building.ToolchainsBu
     @Override
     public ToolchainsBuilderResult build(ToolchainsBuilderRequest request)
             throws ToolchainsBuilderException, IllegalArgumentException {
-        DefaultSession session = (DefaultSession) request.getSession();
         try {
             DefaultToolchainsBuildingRequest req = new DefaultToolchainsBuildingRequest();
-            if (request.getGlobalToolchainsSource().isPresent()) {
-                req.setGlobalToolchainsSource(new MappedToolchainsSource(
-                        request.getGlobalToolchainsSource().get()));
-            } else if (request.getGlobalToolchainsPath().isPresent()) {
-                req.setGlobalToolchainsSource(new org.apache.maven.building.FileSource(
-                        request.getGlobalToolchainsPath().get().toFile()));
-            }
-            if (request.getUserToolchainsSource().isPresent()) {
-                req.setUserToolchainsSource(new MappedToolchainsSource(
-                        request.getUserToolchainsSource().get()));
-            } else if (request.getUserToolchainsPath().isPresent()) {
-                req.setUserToolchainsSource(new org.apache.maven.building.FileSource(
-                        request.getUserToolchainsPath().get().toFile()));
-            }
+
+            request.getGlobalToolchainsSource()
+                    .ifPresent(s -> req.setGlobalToolchainsSource(new MappedToolchainsSource(s)));
+            request.getGlobalToolchainsPath().ifPresent(s -> req.setGlobalToolchainsSource(new FileSource(s.toFile())));
+
+            request.getUserToolchainsSource()
+                    .ifPresent(s -> req.setUserToolchainsSource(new MappedToolchainsSource(s)));
+            request.getUserToolchainsPath().ifPresent(s -> req.setUserToolchainsSource(new FileSource(s.toFile())));

Review Comment:
   Good catch... thanks.. 



-- 
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: issues-unsubscribe@maven.apache.org

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