Skip to content

Commit

Permalink
Honor --console=plain in Gradle plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Oct 17, 2023
1 parent aaa4830 commit 533b318
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,24 @@ public class NativeImageCommandLineProvider implements CommandLineArgumentProvid
private final Provider<RegularFile> classpathJar;
private final Provider<Boolean> useArgFile;
private final Provider<Integer> majorJDKVersion;
private final Provider<Boolean> useColors;

public NativeImageCommandLineProvider(Provider<NativeImageOptions> options,
Provider<String> executableName,
Provider<String> workingDirectory,
Provider<String> outputDirectory,
Provider<RegularFile> classpathJar,
Provider<Boolean> useArgFile,
Provider<Integer> majorJDKVersion) {
Provider<Integer> majorJDKVersion,
Provider<Boolean> useColors) {
this.options = options;
this.executableName = executableName;
this.workingDirectory = workingDirectory;
this.outputDirectory = outputDirectory;
this.classpathJar = classpathJar;
this.useArgFile = useArgFile;
this.majorJDKVersion = majorJDKVersion;
this.useColors = useColors;
}

@Nested
Expand Down Expand Up @@ -122,7 +125,9 @@ public List<String> asArguments() {
appendBooleanOption(cliArgs, options.getVerbose(), "--verbose");
appendBooleanOption(cliArgs, options.getSharedLibrary(), "--shared");
appendBooleanOption(cliArgs, options.getQuickBuild(), "-Ob");
appendBooleanOption(cliArgs, options.getRichOutput(), majorJDKVersion.getOrElse(-1) >= 21 ? "--color" : "-H:+BuildOutputColorful");
if (useColors.get()) {
appendBooleanOption(cliArgs, options.getRichOutput(), majorJDKVersion.getOrElse(-1) >= 21 ? "--color" : "-H:+BuildOutputColorful");
}
appendBooleanOption(cliArgs, options.getPgoInstrument(), "--pgo-instrument");

String targetOutputPath = getExecutableName().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ private List<String> buildActualCommandLineArgs(int majorJDKVersion) {
getProviders().provider(() -> getOutputDirectory().getAsFile().get().getAbsolutePath()),
getClasspathJar(),
getUseArgFile(),
getProviders().provider(() -> majorJDKVersion)).asArguments();
getProviders().provider(() -> majorJDKVersion),
getProviders().provider(() -> "plain".equals(getProject().getGradle().getStartParameter().getConsoleOutput()))).asArguments();
}

// This property provides access to the service instance
Expand Down

0 comments on commit 533b318

Please sign in to comment.