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 <elh...@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; } }