mirror of
https://github.com/actions/setup-java.git
synced 2026-11-14 13:10:34 +08:00
Make Java problem matcher opt-in (#1326)
Default the problem-matcher input to false so setup-java no longer registers Java compiler and uncaught-exception annotations unless explicitly enabled with problem-matcher: true. Fixes #1322 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot App
parent
5fb63c9bc9
commit
d1374f8ac7
@@ -59,7 +59,7 @@ steps:
|
|||||||
- Warm JDK-cached jobs can reuse cached release metadata, avoiding vendor API calls while retaining a stale-metadata fallback for vendor outages and rate limits.
|
- Warm JDK-cached jobs can reuse cached release metadata, avoiding vendor API calls while retaining a stale-metadata fallback for vendor outages and rate limits.
|
||||||
- Maven configuration now supports multiple server credentials and custom dependency-resolution repositories.
|
- Maven configuration now supports multiple server credentials and custom dependency-resolution repositories.
|
||||||
- Maven signing keys are imported into an isolated temporary GPG home instead of the runner's default keyring.
|
- Maven signing keys are imported into an isolated temporary GPG home instead of the runner's default keyring.
|
||||||
- Set `problem-matcher: false` to disable Java compiler and uncaught-exception annotations.
|
- Java compiler and uncaught-exception annotations are now disabled by default. Set `problem-matcher: true` to enable them.
|
||||||
- GraalVM distributions now set `GRAALVM_HOME` in addition to `JAVA_HOME`.
|
- GraalVM distributions now set `GRAALVM_HOME` in addition to `JAVA_HOME`.
|
||||||
- Invalid boolean values, unsupported distribution/package/platform combinations, and mismatched Maven toolchain ID counts now fail with targeted errors.
|
- Invalid boolean values, unsupported distribution/package/platform combinations, and mismatched Maven toolchain ID counts now fail with targeted errors.
|
||||||
- Renamed environment-variable-name inputs so they are not mistaken for secret values:
|
- Renamed environment-variable-name inputs so they are not mistaken for secret values:
|
||||||
@@ -155,7 +155,7 @@ steps:
|
|||||||
| `check-latest` | Check remote metadata for the latest version satisfying the version spec before using the runner tool cache. | `false` |
|
| `check-latest` | Check remote metadata for the latest version satisfying the version spec before using the runner tool cache. | `false` |
|
||||||
| `force-download` | Always download Java and replace any matching version in the tool cache. | `false` |
|
| `force-download` | Always download Java and replace any matching version in the tool cache. | `false` |
|
||||||
| `set-default` | Add Java to `PATH` and set `JAVA_HOME`. When `false`, only version-specific `JAVA_HOME_<major>_<arch>` variables are set. | `true` |
|
| `set-default` | Add Java to `PATH` and set `JAVA_HOME`. When `false`, only version-specific `JAVA_HOME_<major>_<arch>` variables are set. | `true` |
|
||||||
| `problem-matcher` | Register Java compiler and uncaught exception problem matchers. | `true` |
|
| `problem-matcher` | Register Java compiler and uncaught exception problem matchers. | `false` |
|
||||||
| `verify-signature` | Verify downloaded Java package signatures when supported. Explicitly setting this to `true` makes verification failures fatal. | Distribution-dependent; see [Download integrity and signatures](#download-integrity-and-signatures) |
|
| `verify-signature` | Verify downloaded Java package signatures when supported. Explicitly setting this to `true` makes verification failures fatal. | Distribution-dependent; see [Download integrity and signatures](#download-integrity-and-signatures) |
|
||||||
| `verify-signature-public-key` | One or more ASCII-armored GPG public keys used for signature verification. Concatenate multiple armored key blocks. Custom keys replace the bundled distribution keys. | |
|
| `verify-signature-public-key` | One or more ASCII-armored GPG public keys used for signature verification. Concatenate multiple armored key blocks. Custom keys replace the bundled distribution keys. | |
|
||||||
| `token` | Token for fetching GitHub.com-hosted version manifests, useful on GitHub Enterprise Server when unauthenticated requests are rate-limited. | `${{ github.token }}` on GitHub.com; empty string on GHES |
|
| `token` | Token for fetching GitHub.com-hosted version manifests, useful on GitHub Enterprise Server when unauthenticated requests are rate-limited. | `${{ github.token }}` on GitHub.com; empty string on GHES |
|
||||||
|
|||||||
@@ -27,7 +27,16 @@ describe('configureProblemMatcher', () => {
|
|||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('registers the Java problem matcher by default', () => {
|
it('does not register the Java problem matcher by default', () => {
|
||||||
|
configureProblemMatcher('/matchers/java.json');
|
||||||
|
|
||||||
|
expect(mockInfo).not.toHaveBeenCalled();
|
||||||
|
expect(mockDebug).toHaveBeenCalledWith('Java problem matcher is disabled');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('registers the Java problem matcher when explicitly enabled', () => {
|
||||||
|
inputs[INPUT_PROBLEM_MATCHER] = 'true';
|
||||||
|
|
||||||
configureProblemMatcher('/matchers/java.json');
|
configureProblemMatcher('/matchers/java.json');
|
||||||
|
|
||||||
expect(mockInfo).toHaveBeenCalledWith('##[add-matcher]/matchers/java.json');
|
expect(mockInfo).toHaveBeenCalledWith('##[add-matcher]/matchers/java.json');
|
||||||
|
|||||||
+2
-2
@@ -138,9 +138,9 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
problem-matcher:
|
problem-matcher:
|
||||||
description: 'Whether to register the Java problem matcher (compiler errors/warnings and uncaught exceptions). Set to "false" to disable annotations.'
|
description: 'Whether to register the Java problem matcher (compiler errors/warnings and uncaught exceptions). Disabled by default; set to "true" to enable annotations.'
|
||||||
required: false
|
required: false
|
||||||
default: true
|
default: false
|
||||||
outputs:
|
outputs:
|
||||||
distribution:
|
distribution:
|
||||||
description: 'Distribution of Java that has been installed'
|
description: 'Distribution of Java that has been installed'
|
||||||
|
|||||||
Vendored
+1
-1
@@ -36747,7 +36747,7 @@ async function getJavaDistribution(distributionName, installerOptions, jdkFile)
|
|||||||
|
|
||||||
|
|
||||||
function configureProblemMatcher(matcherPath) {
|
function configureProblemMatcher(matcherPath) {
|
||||||
const problemMatcherEnabled = (0,util/* getBooleanInput */.Vt)(constants/* INPUT_PROBLEM_MATCHER */.Wt, true);
|
const problemMatcherEnabled = (0,util/* getBooleanInput */.Vt)(constants/* INPUT_PROBLEM_MATCHER */.Wt, false);
|
||||||
if (!problemMatcherEnabled) {
|
if (!problemMatcherEnabled) {
|
||||||
setup_java_core/* debug */.Yz('Java problem matcher is disabled');
|
setup_java_core/* debug */.Yz('Java problem matcher is disabled');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1310,7 +1310,7 @@ jobs:
|
|||||||
|
|
||||||
## Java problem matcher (compiler annotations)
|
## Java problem matcher (compiler annotations)
|
||||||
|
|
||||||
By default, `setup-java` registers a [problem matcher](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) for Java after installing the JDK. It scans the log output of subsequent steps and turns Java diagnostics into GitHub [annotations](https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message) that appear in the run summary and inline on the affected files. It matches three kinds of lines:
|
Java [problem matcher](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md) registration is disabled by default. Set `problem-matcher: true` to have `setup-java` register the matcher after installing the JDK. When enabled, it scans the log output of subsequent steps and turns Java diagnostics into GitHub [annotations](https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message) that appear in the run summary and inline on the affected files. It matches three kinds of lines:
|
||||||
|
|
||||||
- Compiler errors and warnings, e.g. `App.java:12: error: cannot find symbol` (owner `javac`).
|
- Compiler errors and warnings, e.g. `App.java:12: error: cannot find symbol` (owner `javac`).
|
||||||
- Maven compiler errors and warnings, e.g. `[ERROR] /path/App.java:[12,5] cannot find symbol` (owner `maven-javac`).
|
- Maven compiler errors and warnings, e.g. `[ERROR] /path/App.java:[12,5] cannot find symbol` (owner `maven-javac`).
|
||||||
@@ -1318,9 +1318,9 @@ By default, `setup-java` registers a [problem matcher](https://github.com/action
|
|||||||
|
|
||||||
GitHub Actions limits problem matcher annotations to 10 of each severity per step and 50 annotations per job. Additional diagnostics remain available in the build log. Log grouping does not change these limits because every matched diagnostic still counts as an annotation.
|
GitHub Actions limits problem matcher annotations to 10 of each severity per step and 50 annotations per job. Additional diagnostics remain available in the build log. Log grouping does not change these limits because every matched diagnostic still counts as an annotation.
|
||||||
|
|
||||||
### Disabling the problem matcher
|
### Enabling the problem matcher
|
||||||
|
|
||||||
Set `problem-matcher` to `false` to prevent the matcher from being registered:
|
Set `problem-matcher` to `true` to enable annotations, including in workflows that previously relied on default registration:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
@@ -1333,13 +1333,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: '<distribution>'
|
distribution: '<distribution>'
|
||||||
java-version: '21'
|
java-version: '21'
|
||||||
problem-matcher: false
|
problem-matcher: true
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn package --file pom.xml
|
run: mvn package --file pom.xml
|
||||||
```
|
```
|
||||||
|
|
||||||
Disabling the matcher only stops annotations from being created. Compiler output remains in the log, and compilation errors still fail the build step.
|
Omit `problem-matcher` or set it to `false` to prevent this action invocation from registering the matcher. Compiler output remains in the log, and compilation errors still fail the build step. This does not unregister matchers already registered by other steps or earlier action invocations.
|
||||||
|
|
||||||
## Publishing using Gradle
|
## Publishing using Gradle
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {INPUT_PROBLEM_MATCHER} from './constants.js';
|
|||||||
import {getBooleanInput} from './util.js';
|
import {getBooleanInput} from './util.js';
|
||||||
|
|
||||||
export function configureProblemMatcher(matcherPath: string): void {
|
export function configureProblemMatcher(matcherPath: string): void {
|
||||||
const problemMatcherEnabled = getBooleanInput(INPUT_PROBLEM_MATCHER, true);
|
const problemMatcherEnabled = getBooleanInput(INPUT_PROBLEM_MATCHER, false);
|
||||||
|
|
||||||
if (!problemMatcherEnabled) {
|
if (!problemMatcherEnabled) {
|
||||||
core.debug('Java problem matcher is disabled');
|
core.debug('Java problem matcher is disabled');
|
||||||
|
|||||||
Reference in New Issue
Block a user