You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2024/12/18 15:21:59 UTC

(maven-jmod-plugin) branch close created (now ea371e0)

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

elharo pushed a change to branch close
in repository https://gitbox.apache.org/repos/asf/maven-jmod-plugin.git


      at ea371e0  avoid IO

This branch includes the following new commits:

     new 476ea84  avoid IO
     new ea371e0  avoid IO

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-jmod-plugin) 02/02: avoid IO

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch close
in repository https://gitbox.apache.org/repos/asf/maven-jmod-plugin.git

commit ea371e0d16e7697ddf16f8ba9c67942379974cb7
Merge: 476ea84 79aa4b8
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Wed Dec 18 10:21:52 2024 -0500

    avoid IO

 src/it/list-base-config/verify.groovy | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --cc src/it/list-base-config/verify.groovy
index a854396,a854396..8cddfc7
--- a/src/it/list-base-config/verify.groovy
+++ b/src/it/list-base-config/verify.groovy
@@@ -26,8 -26,8 +26,7 @@@ def resourceNames = 
  def buildLog = new File (basedir, 'build.log')
  
  def listLines = buildLog.readLines()
--                            .dropWhile{ !it.startsWith('[INFO] The following files are contained in the module file') }
--                            .drop(1)
++                            .dropWhile{ !it.startsWith('[INFO] ---') }
                              .takeWhile{ !it.startsWith('[INFO] ---') }
                              .findAll{ it.startsWith('[INFO] ')}
                              .collect{ it - '[INFO] ' } as Set


(maven-jmod-plugin) 01/02: avoid IO

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch close
in repository https://gitbox.apache.org/repos/asf/maven-jmod-plugin.git

commit 476ea84c4730b0dec2a01896bdf57542161cd5dd
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Wed Dec 18 10:19:32 2024 -0500

    avoid IO
---
 .../apache/maven/plugins/jmod/JModListMojo.java    | 40 +++++-----------------
 1 file changed, 9 insertions(+), 31 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/jmod/JModListMojo.java b/src/main/java/org/apache/maven/plugins/jmod/JModListMojo.java
index 133fa38..297f4ed 100644
--- a/src/main/java/org/apache/maven/plugins/jmod/JModListMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jmod/JModListMojo.java
@@ -22,8 +22,6 @@ import javax.inject.Inject;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.Writer;
-import java.nio.file.Files;
 
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -46,7 +44,7 @@ public class JModListMojo extends AbstractJModMojo {
     private File outputDirectory;
 
     /**
-     * The name of the jmod file which is used to be examined via <code>jmod list jmodFile</code>
+     * The name of the jmod file which is examined via <code>jmod list jmodFile</code>.
      */
     // @formatter:off
     @Parameter(
@@ -72,40 +70,20 @@ public class JModListMojo extends AbstractJModMojo {
 
         getLog().info("Toolchain in maven-jmod-plugin: jmod [ " + jModExecutable + " ]");
 
-        if (!jmodFile.exists() || !jmodFile.isFile()) {
-            throw new MojoFailureException("Unable to find " + jmodFile.getAbsolutePath());
-        }
-
-        Commandline cmd;
-        try {
-            cmd = createJModListCommandLine(jmodFile);
-        } catch (IOException e) {
-            throw new MojoExecutionException(e.getMessage());
-        }
+        Commandline cmd = createJModListCommandLine();
         cmd.setExecutable(jModExecutable);
 
-        getLog().info("The following files are contained in the module file " + jmodFile.getAbsolutePath());
         executeCommand(cmd, outputDirectory);
     }
 
-    private Commandline createJModListCommandLine(File resultingJModFile) throws IOException {
-        File file = new File(outputDirectory, "jmodListArgs");
-        if (!getLog().isDebugEnabled()) {
-            file.deleteOnExit();
+    private Commandline createJModListCommandLine() throws MojoFailureException {
+        if (!jmodFile.exists() || !jmodFile.isFile()) {
+            throw new MojoFailureException("Unable to find " + jmodFile.getAbsolutePath());
         }
-        file.getParentFile().mkdirs();
-        file.createNewFile();
-
-        try (Writer out = Files.newBufferedWriter(file.toPath())) {
-            out.write("list\n");
 
-            out.write(resultingJModFile.getAbsolutePath());
-            out.write("\n");
-
-            Commandline cmd = new Commandline();
-            cmd.createArg().setValue('@' + file.getAbsolutePath());
-
-            return cmd;
-        }
+        Commandline commandLine = new Commandline();
+        commandLine.createArg().setValue("list");
+        commandLine.createArg().setValue(jmodFile.getAbsolutePath());
+        return commandLine;
     }
 }