mirror of
https://github.com/actions/setup-java.git
synced 2026-06-23 08:19:41 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa20c15c93 | |||
| 8e27c114ea | |||
| cf3151c7a1 |
@@ -0,0 +1,104 @@
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import {configureMavenArgs} from '../src/maven-args';
|
||||
import {
|
||||
INPUT_SHOW_DOWNLOAD_PROGRESS,
|
||||
MAVEN_ARGS_ENV,
|
||||
MAVEN_NO_TRANSFER_PROGRESS_FLAG
|
||||
} from '../src/constants';
|
||||
|
||||
describe('configureMavenArgs', () => {
|
||||
let inputs: Record<string, string>;
|
||||
let spyGetInput: jest.SpyInstance;
|
||||
let spyExportVariable: jest.SpyInstance;
|
||||
let spyInfo: jest.SpyInstance;
|
||||
let spyDebug: jest.SpyInstance;
|
||||
const originalMavenArgs = process.env[MAVEN_ARGS_ENV];
|
||||
|
||||
beforeEach(() => {
|
||||
inputs = {};
|
||||
|
||||
spyGetInput = jest.spyOn(core, 'getInput');
|
||||
spyGetInput.mockImplementation((name: string) => inputs[name] ?? '');
|
||||
|
||||
spyExportVariable = jest.spyOn(core, 'exportVariable');
|
||||
spyExportVariable.mockImplementation((name: string, value: string) => {
|
||||
process.env[name] = value;
|
||||
});
|
||||
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => undefined);
|
||||
|
||||
spyDebug = jest.spyOn(core, 'debug');
|
||||
spyDebug.mockImplementation(() => undefined);
|
||||
|
||||
delete process.env[MAVEN_ARGS_ENV];
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
if (originalMavenArgs === undefined) {
|
||||
delete process.env[MAVEN_ARGS_ENV];
|
||||
} else {
|
||||
process.env[MAVEN_ARGS_ENV] = originalMavenArgs;
|
||||
}
|
||||
});
|
||||
|
||||
it('sets MAVEN_ARGS with -ntp by default', () => {
|
||||
configureMavenArgs();
|
||||
|
||||
expect(spyExportVariable).toHaveBeenCalledWith(
|
||||
MAVEN_ARGS_ENV,
|
||||
MAVEN_NO_TRANSFER_PROGRESS_FLAG
|
||||
);
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBe(MAVEN_NO_TRANSFER_PROGRESS_FLAG);
|
||||
});
|
||||
|
||||
it('does not modify MAVEN_ARGS when show-download-progress is true', () => {
|
||||
inputs[INPUT_SHOW_DOWNLOAD_PROGRESS] = 'true';
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBeUndefined();
|
||||
});
|
||||
|
||||
it('preserves an existing MAVEN_ARGS value and appends -ntp', () => {
|
||||
process.env[MAVEN_ARGS_ENV] = '-B -Dstyle.color=always';
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(spyExportVariable).toHaveBeenCalledWith(
|
||||
MAVEN_ARGS_ENV,
|
||||
`-B -Dstyle.color=always ${MAVEN_NO_TRANSFER_PROGRESS_FLAG}`
|
||||
);
|
||||
});
|
||||
|
||||
it('does not duplicate the flag when -ntp is already present', () => {
|
||||
process.env[MAVEN_ARGS_ENV] = '-B -ntp';
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBe('-B -ntp');
|
||||
});
|
||||
|
||||
it('does not duplicate the flag when --no-transfer-progress is already present', () => {
|
||||
process.env[MAVEN_ARGS_ENV] = '--no-transfer-progress -B';
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBe('--no-transfer-progress -B');
|
||||
});
|
||||
|
||||
it('keeps the existing MAVEN_ARGS when show-download-progress is true', () => {
|
||||
inputs[INPUT_SHOW_DOWNLOAD_PROGRESS] = 'true';
|
||||
process.env[MAVEN_ARGS_ENV] = '-B';
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBe('-B');
|
||||
});
|
||||
});
|
||||
@@ -75,6 +75,10 @@ inputs:
|
||||
mvn-toolchain-vendor:
|
||||
description: 'Name of Maven Toolchain Vendor if the default name of "${distribution}" is not wanted. See examples of supported syntax in Advanced Usage file'
|
||||
required: false
|
||||
show-download-progress:
|
||||
description: 'Whether Maven should print artifact download/transfer progress to the build log. When "false" (default) the action sets "-ntp" (--no-transfer-progress) in MAVEN_ARGS to produce cleaner logs. Set to "true" to keep the progress output. Has no effect on non-Maven builds.'
|
||||
required: false
|
||||
default: false
|
||||
outputs:
|
||||
distribution:
|
||||
description: 'Distribution of Java that has been installed'
|
||||
|
||||
Vendored
+5
-1
@@ -52241,7 +52241,7 @@ else {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||
@@ -52268,6 +52268,10 @@ exports.MVN_SETTINGS_FILE = 'settings.xml';
|
||||
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
||||
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
||||
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
||||
exports.INPUT_SHOW_DOWNLOAD_PROGRESS = 'show-download-progress';
|
||||
exports.MAVEN_ARGS_ENV = 'MAVEN_ARGS';
|
||||
exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = '-ntp';
|
||||
exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = '--no-transfer-progress';
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];
|
||||
|
||||
|
||||
|
||||
Vendored
+88
-1
@@ -78000,7 +78000,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = exports.MAVEN_ARGS_ENV = exports.INPUT_SHOW_DOWNLOAD_PROGRESS = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||
@@ -78027,6 +78027,10 @@ exports.MVN_SETTINGS_FILE = 'settings.xml';
|
||||
exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
||||
exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
||||
exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
||||
exports.INPUT_SHOW_DOWNLOAD_PROGRESS = 'show-download-progress';
|
||||
exports.MAVEN_ARGS_ENV = 'MAVEN_ARGS';
|
||||
exports.MAVEN_NO_TRANSFER_PROGRESS_FLAG = '-ntp';
|
||||
exports.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = '--no-transfer-progress';
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];
|
||||
|
||||
|
||||
@@ -80889,6 +80893,87 @@ function deleteKey(keyFingerprint) {
|
||||
exports.deleteKey = deleteKey;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 38172:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.configureMavenArgs = void 0;
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const util_1 = __nccwpck_require__(54527);
|
||||
const constants_1 = __nccwpck_require__(27242);
|
||||
/**
|
||||
* Configures the MAVEN_ARGS environment variable so that Maven suppresses
|
||||
* artifact transfer/download progress output by default, producing cleaner
|
||||
* CI logs.
|
||||
*
|
||||
* Behavior:
|
||||
* - When `show-download-progress` is `false` (the default), `-ntp`
|
||||
* (`--no-transfer-progress`) is appended to any existing MAVEN_ARGS value.
|
||||
* - When `show-download-progress` is `true`, MAVEN_ARGS is left untouched so
|
||||
* the user's own configuration (and Maven's default progress output) is
|
||||
* preserved.
|
||||
*
|
||||
* The change is idempotent: if MAVEN_ARGS already disables transfer progress
|
||||
* (via `-ntp` or `--no-transfer-progress`) nothing is added. Any pre-existing
|
||||
* MAVEN_ARGS value is preserved.
|
||||
*
|
||||
* MAVEN_ARGS is honored by Maven 3.9.0+ and the Maven Wrapper; older Maven
|
||||
* versions ignore it, so this is a no-op there. It has no effect on non-Maven
|
||||
* builds such as Gradle or sbt.
|
||||
*/
|
||||
function configureMavenArgs() {
|
||||
var _a;
|
||||
const showDownloadProgress = (0, util_1.getBooleanInput)(constants_1.INPUT_SHOW_DOWNLOAD_PROGRESS, false);
|
||||
if (showDownloadProgress) {
|
||||
core.debug(`${constants_1.INPUT_SHOW_DOWNLOAD_PROGRESS} is true; leaving ${constants_1.MAVEN_ARGS_ENV} unchanged`);
|
||||
return;
|
||||
}
|
||||
const existingArgs = ((_a = process.env[constants_1.MAVEN_ARGS_ENV]) !== null && _a !== void 0 ? _a : '').trim();
|
||||
const alreadyDisabled = existingArgs
|
||||
.split(/\s+/)
|
||||
.some(arg => arg === constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG ||
|
||||
arg === constants_1.MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG);
|
||||
if (alreadyDisabled) {
|
||||
core.debug(`${constants_1.MAVEN_ARGS_ENV} already disables transfer progress; leaving it unchanged`);
|
||||
return;
|
||||
}
|
||||
const updatedArgs = existingArgs
|
||||
? `${existingArgs} ${constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG}`
|
||||
: constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG;
|
||||
core.exportVariable(constants_1.MAVEN_ARGS_ENV, updatedArgs);
|
||||
core.info(`Configured ${constants_1.MAVEN_ARGS_ENV} to include ${constants_1.MAVEN_NO_TRANSFER_PROGRESS_FLAG} to suppress Maven transfer progress logs. ` +
|
||||
`Set '${constants_1.INPUT_SHOW_DOWNLOAD_PROGRESS}: true' to keep the download progress output.`);
|
||||
}
|
||||
exports.configureMavenArgs = configureMavenArgs;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 90471:
|
||||
@@ -80941,6 +81026,7 @@ const constants = __importStar(__nccwpck_require__(27242));
|
||||
const cache_1 = __nccwpck_require__(97377);
|
||||
const path = __importStar(__nccwpck_require__(16928));
|
||||
const distribution_factory_1 = __nccwpck_require__(2970);
|
||||
const maven_args_1 = __nccwpck_require__(38172);
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
@@ -80988,6 +81074,7 @@ function run() {
|
||||
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||
yield auth.configureAuthentication();
|
||||
(0, maven_args_1.configureMavenArgs)();
|
||||
if (cache && (0, util_1.isCacheFeatureAvailable)()) {
|
||||
yield (0, cache_1.restore)(cache, cacheDependencyPath);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
- [Testing against different Java distributions](#Testing-against-different-Java-distributions)
|
||||
- [Testing against different platforms](#Testing-against-different-platforms)
|
||||
- [Publishing using Apache Maven](#Publishing-using-Apache-Maven)
|
||||
- [Maven transfer progress (download logs)](#Maven-transfer-progress-download-logs)
|
||||
- [Publishing using Gradle](#Publishing-using-Gradle)
|
||||
- [Hosted Tool Cache](#Hosted-Tool-Cache)
|
||||
- [Modifying Maven Toolchains](#Modifying-Maven-Toolchains)
|
||||
@@ -490,6 +491,36 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
```
|
||||
|
||||
## Maven transfer progress (download logs)
|
||||
|
||||
By default, Maven prints a line for every artifact it downloads, which can add hundreds of noisy lines to CI logs. To keep logs clean, `setup-java` sets the [`MAVEN_ARGS`](https://maven.apache.org/configure.html#maven_args-environment-variable) environment variable to include `-ntp` (`--no-transfer-progress`) so that subsequent Maven invocations in the job suppress this transfer progress output.
|
||||
|
||||
This is enabled by default. Any existing `MAVEN_ARGS` value is preserved (the flag is appended, not overwritten), and the flag is not added twice if you already set it yourself.
|
||||
|
||||
If you want to keep the download/transfer progress in your logs, set `show-download-progress: true`:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: '21'
|
||||
show-download-progress: true # keep Maven download/transfer progress in the logs
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
```
|
||||
|
||||
***NOTES***:
|
||||
- `MAVEN_ARGS` is honored by Maven 3.9.0+ and the Maven Wrapper (`mvnw`). Older Maven versions ignore it, so on those you can pass `--no-transfer-progress` on the command line instead.
|
||||
- This setting only affects Maven. It has no effect on Gradle, sbt, or other build tools.
|
||||
- `-ntp` only controls transfer/progress output; it does not change whether Maven runs in batch mode. Use `-B`/`--batch-mode` (or `<interactiveMode>false</interactiveMode>` in `settings.xml`) if you also want non-interactive runs.
|
||||
|
||||
## Publishing using Gradle
|
||||
```yaml
|
||||
jobs:
|
||||
|
||||
@@ -28,5 +28,10 @@ export const MVN_SETTINGS_FILE = 'settings.xml';
|
||||
export const MVN_TOOLCHAINS_FILE = 'toolchains.xml';
|
||||
export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
|
||||
export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
|
||||
export const INPUT_SHOW_DOWNLOAD_PROGRESS = 'show-download-progress';
|
||||
|
||||
export const MAVEN_ARGS_ENV = 'MAVEN_ARGS';
|
||||
export const MAVEN_NO_TRANSFER_PROGRESS_FLAG = '-ntp';
|
||||
export const MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG = '--no-transfer-progress';
|
||||
|
||||
export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import * as core from '@actions/core';
|
||||
import {getBooleanInput} from './util';
|
||||
import {
|
||||
INPUT_SHOW_DOWNLOAD_PROGRESS,
|
||||
MAVEN_ARGS_ENV,
|
||||
MAVEN_NO_TRANSFER_PROGRESS_FLAG,
|
||||
MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
* Configures the MAVEN_ARGS environment variable so that Maven suppresses
|
||||
* artifact transfer/download progress output by default, producing cleaner
|
||||
* CI logs.
|
||||
*
|
||||
* Behavior:
|
||||
* - When `show-download-progress` is `false` (the default), `-ntp`
|
||||
* (`--no-transfer-progress`) is appended to any existing MAVEN_ARGS value.
|
||||
* - When `show-download-progress` is `true`, MAVEN_ARGS is left untouched so
|
||||
* the user's own configuration (and Maven's default progress output) is
|
||||
* preserved.
|
||||
*
|
||||
* The change is idempotent: if MAVEN_ARGS already disables transfer progress
|
||||
* (via `-ntp` or `--no-transfer-progress`) nothing is added. Any pre-existing
|
||||
* MAVEN_ARGS value is preserved.
|
||||
*
|
||||
* MAVEN_ARGS is honored by Maven 3.9.0+ and the Maven Wrapper; older Maven
|
||||
* versions ignore it, so this is a no-op there. It has no effect on non-Maven
|
||||
* builds such as Gradle or sbt.
|
||||
*/
|
||||
export function configureMavenArgs(): void {
|
||||
const showDownloadProgress = getBooleanInput(
|
||||
INPUT_SHOW_DOWNLOAD_PROGRESS,
|
||||
false
|
||||
);
|
||||
|
||||
if (showDownloadProgress) {
|
||||
core.debug(
|
||||
`${INPUT_SHOW_DOWNLOAD_PROGRESS} is true; leaving ${MAVEN_ARGS_ENV} unchanged`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const existingArgs = (process.env[MAVEN_ARGS_ENV] ?? '').trim();
|
||||
|
||||
const alreadyDisabled = existingArgs
|
||||
.split(/\s+/)
|
||||
.some(
|
||||
arg =>
|
||||
arg === MAVEN_NO_TRANSFER_PROGRESS_FLAG ||
|
||||
arg === MAVEN_NO_TRANSFER_PROGRESS_LONG_FLAG
|
||||
);
|
||||
|
||||
if (alreadyDisabled) {
|
||||
core.debug(
|
||||
`${MAVEN_ARGS_ENV} already disables transfer progress; leaving it unchanged`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedArgs = existingArgs
|
||||
? `${existingArgs} ${MAVEN_NO_TRANSFER_PROGRESS_FLAG}`
|
||||
: MAVEN_NO_TRANSFER_PROGRESS_FLAG;
|
||||
|
||||
core.exportVariable(MAVEN_ARGS_ENV, updatedArgs);
|
||||
core.info(
|
||||
`Configured ${MAVEN_ARGS_ENV} to include ${MAVEN_NO_TRANSFER_PROGRESS_FLAG} to suppress Maven transfer progress logs. ` +
|
||||
`Set '${INPUT_SHOW_DOWNLOAD_PROGRESS}: true' to keep the download progress output.`
|
||||
);
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import {restore} from './cache';
|
||||
import * as path from 'path';
|
||||
import {getJavaDistribution} from './distributions/distribution-factory';
|
||||
import {JavaInstallerOptions} from './distributions/base-models';
|
||||
import {configureMavenArgs} from './maven-args';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
@@ -79,6 +80,7 @@ async function run() {
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||
|
||||
await auth.configureAuthentication();
|
||||
configureMavenArgs();
|
||||
if (cache && isCacheFeatureAvailable()) {
|
||||
await restore(cache, cacheDependencyPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user