Skip to content
Merged
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 @@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand All @@ -37,6 +38,13 @@
public final class ToolchainFlowAction implements FlowAction<Parameters> {

private static final Logger log = LoggerFactory.getLogger(ToolchainFlowAction.class);

// This internal exception was renamed in https://github.com/gradle/gradle/pull/29166 and
// https://github.com/gradle/gradle/pull/29376
private static final Set<String> TOOLCHAIN_EXCEPTIONS = Set.of(
"org.gradle.jvm.toolchain.internal.NoToolchainAvailableException",
"org.gradle.jvm.toolchain.internal.install.exceptions.ToolchainProvisioningException");
Comment on lines +42 to +46
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an alternative solution that does not requiring using internal types?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Briefly looking, I don't think so. This is definitely the less risky way of checking the exception, although it does mean this feature may break without us knowing this is what the tests in this repo should be checking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded test versions strike again - will follow up with fixing that.


private static final Pattern LANGUAGE_VERSION_PATTERN = Pattern.compile("languageVersion=(\\d+)");
private static final String ANSI_RED_COLOR = "\u001B[31m";
private static final String ANSI_RESET_COLOR = "\u001B[0m";
Expand All @@ -55,7 +63,7 @@ public void execute(Parameters parameters) {
parameters.getBuildResult().get().getFailure().ifPresent(failure -> {
List<Throwable> noToolchainsAvailable = Throwables.getCausalChain(failure).stream()
.filter(throwable ->
throwable instanceof org.gradle.jvm.toolchain.internal.NoToolchainAvailableException)
TOOLCHAIN_EXCEPTIONS.contains(throwable.getClass().getName()))
.collect(Collectors.toList());
if (noToolchainsAvailable.isEmpty()) {
return;
Expand Down