Skip to content

Commit

Permalink
Replaced with maven assembly plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Mar 6, 2024
1 parent f948894 commit cb80b81
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
1 change: 1 addition & 0 deletions args4j-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<groupId>args4j</groupId>
<artifactId>args4j-tools</artifactId>
<version>${project.version}</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.kohsuke.args4j.apt.Main;

import java.io.*;
import java.lang.ProcessBuilder.Redirect;
import java.net.URLDecoder;
import java.util.List;

Expand Down Expand Up @@ -85,14 +86,13 @@ private void generateUsage(String sourceFile, File args4jBuildDir) throws Interr
String outputDir = args4jBuildDir.getAbsolutePath();
ProcessBuilder pb = new ProcessBuilder();
pb.command("java","-jar", jar.getAbsolutePath(), "-o", outputDir, "-mode", mode, sourceFile);
pb.redirectError(Redirect.INHERIT);
pb.redirectOutput(Redirect.INHERIT);

printCommand(pb);
Process process = pb.start();

InputStreamReader isr = dumpOutput(process);
int r = process.waitFor();

isr.close();
if (r !=0)
throw new IOException("args4j generation failed: "+r);
}
Expand All @@ -114,15 +114,4 @@ private File dir(ProcessBuilder pb) {
}
return directory;
}

private InputStreamReader dumpOutput(Process process) throws IOException {
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
return isr;
}
}
24 changes: 24 additions & 0 deletions args4j-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,30 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down

0 comments on commit cb80b81

Please sign in to comment.