Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
then:
buildSucceeded
outputContains "Args file written to: target" + File.separator + "native-image"

when:
mvn '-DquickBuild', '-Pnative', 'native:write-args-file'

then:
buildSucceeded
outputContains "Args file written to: target" + File.separator + "native-image"
file("target/").listFiles().findAll(x->x.name.contains("native-image") && x.name.endsWith(".args")).size() == 1
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
import org.graalvm.buildtools.utils.NativeImageUtils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;

/**
* Persists the arguments file to be used by the native-image command. This can be useful in situations where
Expand All @@ -67,6 +71,24 @@ public class WriteArgsFileMojo extends NativeCompileNoForkMojo {
@Override
public void execute() throws MojoExecutionException {
List<String> args = getBuildArgs();

getLog().debug("Cleaning old native image build args");

try (Stream<Path> listStream = Files.list(outputDirectory.toPath())) {
listStream.map(path -> path.getFileName().toString())
.filter(f -> f.startsWith("native-image") && f.endsWith("args"))
.map(outputDirectory.toPath()::resolve)
.forEach(file -> {
try {
Files.delete(file);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
} catch (IOException e) {
throw new MojoExecutionException(e);
}

List<String> conversionResult = NativeImageUtils.convertToArgsFile(args, outputDirectory.toPath());
if (conversionResult.size() == 1) {
String argsFileName = conversionResult.get(0).replace("@", "");
Expand Down