This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch maven-jar-plugin-4.x
in repository https://gitbox.apache.org/repos/asf/maven-jar-plugin.git

commit 2bf35c0a13596420454536e2b94fc35f1c2e4ae4
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Tue Nov 17 03:32:55 2026 +0000

    Simplify redundant code
---
 .../java/org/apache/maven/plugins/jar/PomDerivation.java    |  6 +++---
 .../java/org/apache/maven/plugins/jar/ToolExecutor.java     | 13 ++++++-------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/jar/PomDerivation.java 
b/src/main/java/org/apache/maven/plugins/jar/PomDerivation.java
index de6abd6..a15ae74 100644
--- a/src/main/java/org/apache/maven/plugins/jar/PomDerivation.java
+++ b/src/main/java/org/apache/maven/plugins/jar/PomDerivation.java
@@ -141,7 +141,7 @@ final class PomDerivation {
         moduleFinder = ModuleFinder.of(allModulePaths);
         if (moduleFinder != null) {
             for (ModuleReference reference : moduleFinder.findAll()) {
-                reference.location().ifPresent((location) -> 
fromURI.put(location, reference));
+                reference.location().ifPresent(location -> 
fromURI.put(location, reference));
             }
         }
         fromDependency = new HashMap<>(dependencies.size());
@@ -366,10 +366,10 @@ final class PomDerivation {
                 if 
(!r.modifiers().contains(ModuleDescriptor.Requires.Modifier.TRANSITIVE)) {
                     modifiers.add(Modifier.RUNTIME);
                 }
-                EnumSet<Modifier> current = requires.computeIfAbsent(r.name(), 
(key) -> modifiers);
+                EnumSet<Modifier> current = requires.computeIfAbsent(r.name(), 
key -> modifiers);
                 if (EXPAND_TRANSITIVE && (current == modifiers || 
current.retainAll(modifiers))) {
                     // Transitive dependencies if not already added or if it 
needs to update modifiers.
-                    findModuleDescriptor(r.name()).ifPresent((td) -> 
addDependencies(td, modifiers));
+                    findModuleDescriptor(r.name()).ifPresent(td -> 
addDependencies(td, modifiers));
                 }
             }
         }
diff --git a/src/main/java/org/apache/maven/plugins/jar/ToolExecutor.java 
b/src/main/java/org/apache/maven/plugins/jar/ToolExecutor.java
index f1d3922..7cbc4dc 100644
--- a/src/main/java/org/apache/maven/plugins/jar/ToolExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/jar/ToolExecutor.java
@@ -151,7 +151,7 @@ final class ToolExecutor {
          * common case where a project sets Automatic-Module-Name to
          * "${project.groupId}.${project.artifactId}" and the artifactId 
contains hyphens (MJAR-596).
          */
-        String pluginName = (manifestFromPlugin != null)
+        String pluginName = manifestFromPlugin != null
                 ? 
manifestFromPlugin.getMainAttributes().getValue(AUTOMATIC_MODULE_NAME)
                 : null;
         if (name.equals(pluginName)) {
@@ -314,8 +314,7 @@ final class ToolExecutor {
         artifactType = mojo.getType();
         outputDirectory = mojo.getOutputDirectory();
         classifier = AbstractJarMojo.nullIfAbsent(mojo.getClassifier());
-        finalName =
-                (mojo.finalName != null) ? mojo.finalName : 
project.getBuild().getFinalName();
+        finalName = mojo.finalName != null ? mojo.finalName : 
project.getBuild().getFinalName();
         forceCreation = mojo.forceCreation;
         outputTimestamp = mojo.getOutputTimestamp();
         validate = mojo.getValidate();
@@ -463,10 +462,10 @@ final class ToolExecutor {
          * merge those entries with the content of `MANIFEST.MF` file found in
          * the files to archive.
          */
-        boolean writeTemporaryManifest = (manifestFromPlugin != null && 
manifestFile == null); // Check <archive>.
+        boolean writeTemporaryManifest = manifestFromPlugin != null && 
manifestFile == null; // Check <archive>.
         Manifest manifest = archive.mergeManifest(manifestFile, 
manifestFromPlugin);
         if (manifest != manifestFromPlugin) {
-            writeTemporaryManifest |= (manifestFromPlugin != null); // Check 
if a merge of two manifests.
+            writeTemporaryManifest |= manifestFromPlugin != null; // Check if 
a merge of two manifests.
         } else if (manifest != null) {
             /*
              * `setMainClass` below removes the Main-Class attribute, and 
`manifestFromPlugin` is
@@ -573,7 +572,7 @@ final class ToolExecutor {
      */
     private int executeJarTool() {
         String[] options = new String[arguments.size()];
-        Arrays.setAll(options, (i) -> arguments.get(i).toString());
+        Arrays.setAll(options, i -> arguments.get(i).toString());
         int status = tool.run(messageWriter, errorWriter, options);
         if (!messages.isEmpty()) {
             logger.info(messages);
@@ -607,7 +606,7 @@ final class ToolExecutor {
             baseDir = relativize(Path.of(System.getProperty("user.dir")), 
baseDir);
             String chdir = baseDir.toString();
             if (!chdir.isEmpty()) {
-                boolean isWindows = (File.separatorChar == '\\');
+                boolean isWindows = File.separatorChar == '\\';
                 commandLine
                         .append(System.lineSeparator())
                         .append("    ")

Reply via email to