mirror of
https://gitea.com/actions/setup-java.git
synced 2026-04-18 05:22:06 +08:00
Compare commits
3 Commits
copilot/up
...
b622de1dfa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b622de1dfa | ||
|
|
c76542e033 | ||
|
|
0756542bc5 |
@@ -129,6 +129,8 @@ Currently, the following distributions are supported:
|
||||
|
||||
**NOTE:** To comply with the GraalVM Free Terms and Conditions (GFTC) license, it is recommended to use GraalVM JDK 17 version 17.0.12, as this is the only version of GraalVM JDK 17 available under the GFTC license. Additionally, it is encouraged to consider upgrading to GraalVM JDK 21, which offers the latest features and improvements.
|
||||
|
||||
**NOTE:** Oracle JDK 17 licensing varies by patch level. As shown on the [JDK 17 Archive](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) (versions up to 17.0.12 are under the [NFTC](https://www.oracle.com/downloads/licenses/no-fee-license.html) license) and the [JDK 17.0.13+ Archive](https://www.oracle.com/java/technologies/javase/jdk17-0-13-later-archive-downloads.html) (versions 17.0.13 and later are under the [OTN](https://www.oracle.com/downloads/licenses/javase-license1.html) license). To stay on the free NFTC license, use `distribution: 'oracle'` with `java-version: '17.0.12'` (or earlier) instead of the floating `'17'`. Alternatively, upgrade to Oracle JDK 21+, which remains under the NFTC license.
|
||||
|
||||
### Caching packages dependencies
|
||||
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ describe('dependency cache', () => {
|
||||
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>;
|
||||
let spyDebug: jest.SpyInstance<void, Parameters<typeof core.debug>>;
|
||||
let spySaveState: jest.SpyInstance<void, Parameters<typeof core.saveState>>;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
workspace = mkdtempSync(join(tmpdir(), 'setup-java-cache-'));
|
||||
@@ -51,6 +52,10 @@ describe('dependency cache', () => {
|
||||
|
||||
spySaveState = jest.spyOn(core, 'saveState');
|
||||
spySaveState.mockImplementation(() => null);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -58,6 +63,10 @@ describe('dependency cache', () => {
|
||||
process.env['GITHUB_WORKSPACE'] = ORIGINAL_GITHUB_WORKSPACE;
|
||||
process.env['RUNNER_OS'] = ORIGINAL_RUNNER_OS;
|
||||
resetState();
|
||||
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('restore', () => {
|
||||
|
||||
@@ -11,19 +11,32 @@ describe('cleanup', () => {
|
||||
Parameters<typeof cache.saveCache>
|
||||
>;
|
||||
let spyJobStatusSuccess: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyWarning = jest.spyOn(core, 'warning');
|
||||
spyWarning.mockImplementation(() => null);
|
||||
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => null);
|
||||
|
||||
spyCacheSave = jest.spyOn(cache, 'saveCache');
|
||||
|
||||
spyJobStatusSuccess = jest.spyOn(util, 'isJobStatusSuccess');
|
||||
spyJobStatusSuccess.mockReturnValue(true);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
|
||||
createStateForSuccessfulRestore();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetState();
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('does not fail nor warn even when the save process throws a ReserveCacheError', async () => {
|
||||
|
||||
@@ -9,9 +9,11 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import os from 'os';
|
||||
|
||||
import manifestData from '../data/adopt.json';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -20,6 +22,10 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -262,7 +268,7 @@ describe('findPackageForDownload', () => {
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
await expect(
|
||||
distribution['findPackageForDownload']('9.0.8')
|
||||
).rejects.toThrow(/Could not find satisfied version for SemVer */);
|
||||
).rejects.toThrow(/No matching version found for SemVer */);
|
||||
});
|
||||
|
||||
it('version is not found', async () => {
|
||||
@@ -277,7 +283,7 @@ describe('findPackageForDownload', () => {
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
|
||||
@@ -293,7 +299,7 @@ describe('findPackageForDownload', () => {
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => [];
|
||||
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ class EmptyJavaBase extends JavaBase {
|
||||
): Promise<JavaDownloadRelease> {
|
||||
const availableVersion = '11.0.9';
|
||||
if (!semver.satisfies(availableVersion, range)) {
|
||||
throw new Error('Available version not found');
|
||||
throw this.createVersionNotFoundError(range, [availableVersion]);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -248,6 +248,7 @@ describe('setupJava', () => {
|
||||
let spyCoreExportVariable: jest.SpyInstance;
|
||||
let spyCoreAddPath: jest.SpyInstance;
|
||||
let spyCoreSetOutput: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath');
|
||||
@@ -287,6 +288,10 @@ describe('setupJava', () => {
|
||||
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
||||
spyCoreSetOutput.mockImplementation(() => undefined);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => undefined);
|
||||
|
||||
jest.spyOn(os, 'arch').mockReturnValue('x86' as ReturnType<typeof os.arch>);
|
||||
});
|
||||
|
||||
@@ -530,19 +535,16 @@ describe('setupJava', () => {
|
||||
checkLatest: false
|
||||
}
|
||||
]
|
||||
])(
|
||||
'should throw an error for Available version not found for %s',
|
||||
async input => {
|
||||
mockJavaBase = new EmptyJavaBase(input);
|
||||
await expect(mockJavaBase.setupJava()).rejects.toThrow(
|
||||
'Available version not found'
|
||||
);
|
||||
expect(spyTcFindAllVersions).toHaveBeenCalled();
|
||||
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
||||
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||
expect(spyCoreSetOutput).not.toHaveBeenCalled();
|
||||
}
|
||||
);
|
||||
])('should throw an error for version not found for %s', async input => {
|
||||
mockJavaBase = new EmptyJavaBase(input);
|
||||
await expect(mockJavaBase.setupJava()).rejects.toThrow(
|
||||
`No matching version found for SemVer '${input.version}'`
|
||||
);
|
||||
expect(spyTcFindAllVersions).toHaveBeenCalled();
|
||||
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
||||
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||
expect(spyCoreSetOutput).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizeVersion', () => {
|
||||
@@ -570,6 +572,97 @@ describe('normalizeVersion', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('createVersionNotFoundError', () => {
|
||||
it('should include all required fields in error message without available versions', () => {
|
||||
const mockJavaBase = new EmptyJavaBase({
|
||||
version: '17.0.5',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
const error = (mockJavaBase as any).createVersionNotFoundError('17.0.5');
|
||||
|
||||
expect(error.message).toContain(
|
||||
"No matching version found for SemVer '17.0.5'"
|
||||
);
|
||||
expect(error.message).toContain('Distribution: Empty');
|
||||
expect(error.message).toContain('Package type: jdk');
|
||||
expect(error.message).toContain('Architecture: x64');
|
||||
});
|
||||
|
||||
it('should include available versions when provided', () => {
|
||||
const mockJavaBase = new EmptyJavaBase({
|
||||
version: '17.0.5',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
const availableVersions = ['11.0.1', '11.0.2', '17.0.1', '17.0.2'];
|
||||
const error = (mockJavaBase as any).createVersionNotFoundError(
|
||||
'17.0.5',
|
||||
availableVersions
|
||||
);
|
||||
|
||||
expect(error.message).toContain(
|
||||
"No matching version found for SemVer '17.0.5'"
|
||||
);
|
||||
expect(error.message).toContain('Distribution: Empty');
|
||||
expect(error.message).toContain('Package type: jdk');
|
||||
expect(error.message).toContain('Architecture: x64');
|
||||
expect(error.message).toContain(
|
||||
'Available versions: 11.0.1, 11.0.2, 17.0.1, 17.0.2'
|
||||
);
|
||||
});
|
||||
|
||||
it('should truncate available versions when there are many', () => {
|
||||
const mockJavaBase = new EmptyJavaBase({
|
||||
version: '17.0.5',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
// Create 60 versions to test truncation
|
||||
const availableVersions = Array.from({length: 60}, (_, i) => `11.0.${i}`);
|
||||
const error = (mockJavaBase as any).createVersionNotFoundError(
|
||||
'17.0.5',
|
||||
availableVersions
|
||||
);
|
||||
|
||||
expect(error.message).toContain('Available versions:');
|
||||
expect(error.message).toContain('...');
|
||||
expect(error.message).toContain('(showing first 50 of 60 versions');
|
||||
});
|
||||
|
||||
it('should include additional context when provided', () => {
|
||||
const mockJavaBase = new EmptyJavaBase({
|
||||
version: '17.0.5',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
const availableVersions = ['11.0.1', '11.0.2'];
|
||||
const additionalContext = 'Platform: linux';
|
||||
const error = (mockJavaBase as any).createVersionNotFoundError(
|
||||
'17.0.5',
|
||||
availableVersions,
|
||||
additionalContext
|
||||
);
|
||||
|
||||
expect(error.message).toContain(
|
||||
"No matching version found for SemVer '17.0.5'"
|
||||
);
|
||||
expect(error.message).toContain('Distribution: Empty');
|
||||
expect(error.message).toContain('Package type: jdk');
|
||||
expect(error.message).toContain('Architecture: x64');
|
||||
expect(error.message).toContain('Platform: linux');
|
||||
expect(error.message).toContain('Available versions: 11.0.1, 11.0.2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getToolcacheVersionName', () => {
|
||||
const DummyJavaBase = JavaBase as any;
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import {CorrettoDistribution} from '../../src/distributions/corretto/installer';
|
||||
import * as util from '../../src/util';
|
||||
import os from 'os';
|
||||
import {isGeneratorFunction} from 'util/types';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/corretto.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -23,6 +24,10 @@ describe('getAvailableVersions', () => {
|
||||
util,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -198,7 +203,7 @@ describe('getAvailableVersions', () => {
|
||||
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](version)
|
||||
).rejects.toThrow("Could not find satisfied version for SemVer '4'");
|
||||
).rejects.toThrow("No matching version found for SemVer '4'");
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
|
||||
import * as utils from '../../src/util';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/dragonwell.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -21,6 +23,10 @@ describe('getAvailableVersions', () => {
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -232,7 +238,7 @@ describe('getAvailableVersions', () => {
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](jdkVersion)
|
||||
).rejects.toThrow(
|
||||
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".`
|
||||
`No matching version found for SemVer '${jdkVersion}'`
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -42,6 +42,7 @@ beforeAll(() => {
|
||||
describe('GraalVMDistribution', () => {
|
||||
let distribution: GraalVMDistribution;
|
||||
let mockHttpClient: jest.Mocked<http.HttpClient>;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
const defaultOptions: JavaInstallerOptions = {
|
||||
version: '17',
|
||||
@@ -59,6 +60,10 @@ describe('GraalVMDistribution', () => {
|
||||
(distribution as any).http = mockHttpClient;
|
||||
|
||||
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
@@ -348,11 +353,19 @@ describe('GraalVMDistribution', () => {
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
// Verify the error is thrown with the expected message
|
||||
await expect(
|
||||
(distribution as any).findPackageForDownload('17.0.99')
|
||||
).rejects.toThrow(
|
||||
'Could not find GraalVM for SemVer 17.0.99. Please check if this version is available at https://download.oracle.com/graalvm'
|
||||
);
|
||||
).rejects.toThrow("No matching version found for SemVer '17.0.99'");
|
||||
// Verify distribution info is included
|
||||
await expect(
|
||||
(distribution as any).findPackageForDownload('17.0.99')
|
||||
).rejects.toThrow('GraalVM');
|
||||
|
||||
// Verify the hint about checking the base URL is included
|
||||
await expect(
|
||||
(distribution as any).findPackageForDownload('17.0.99')
|
||||
).rejects.toThrow('https://www.graalvm.org/downloads/');
|
||||
});
|
||||
|
||||
it('should throw error for unauthorized access (401)', async () => {
|
||||
@@ -496,12 +509,19 @@ describe('GraalVMDistribution', () => {
|
||||
|
||||
await expect(
|
||||
(distribution as any).findPackageForDownload('23')
|
||||
).rejects.toThrow("Unable to find latest version for '23-ea'");
|
||||
).rejects.toThrow("No matching version found for SemVer '23-ea'");
|
||||
|
||||
// Verify error logging
|
||||
expect(core.error).toHaveBeenCalledWith(
|
||||
'Available versions: 23-ea-20240716'
|
||||
await expect(
|
||||
(distribution as any).findPackageForDownload('23')
|
||||
).rejects.toThrow(
|
||||
'Note: No EA build is marked as latest for this version.'
|
||||
);
|
||||
|
||||
await expect(
|
||||
(distribution as any).findPackageForDownload('23')
|
||||
).rejects.toThrow('23-ea-20240716');
|
||||
|
||||
// Verify error logging - removed as we now use the helper method which doesn't call core.error
|
||||
});
|
||||
|
||||
it('should throw error when no matching file for architecture in EA build', async () => {
|
||||
@@ -708,11 +728,19 @@ describe('GraalVMDistribution', () => {
|
||||
|
||||
await expect(
|
||||
(distribution as any).findEABuildDownloadUrl('23-ea')
|
||||
).rejects.toThrow("Unable to find latest version for '23-ea'");
|
||||
).rejects.toThrow("No matching version found for SemVer '23-ea'");
|
||||
|
||||
expect(core.error).toHaveBeenCalledWith(
|
||||
'Available versions: 23-ea-20240716, 23-ea-20240709'
|
||||
await expect(
|
||||
(distribution as any).findEABuildDownloadUrl('23-ea')
|
||||
).rejects.toThrow(
|
||||
'Note: No EA build is marked as latest for this version.'
|
||||
);
|
||||
|
||||
await expect(
|
||||
(distribution as any).findEABuildDownloadUrl('23-ea')
|
||||
).rejects.toThrow('23-ea-20240716');
|
||||
|
||||
// Verify error logging - removed as we now use the helper method which doesn't call core.error
|
||||
});
|
||||
|
||||
it('should throw error when no matching file for architecture', async () => {
|
||||
|
||||
@@ -4,9 +4,11 @@ import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer
|
||||
|
||||
import manifestData from '../data/jetbrains.json';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -15,6 +17,10 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -98,7 +104,7 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
await expect(distribution['findPackageForDownload']('8.x')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
|
||||
@@ -111,7 +117,7 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
distribution['getAvailableVersions'] = async () => [];
|
||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,11 +5,13 @@ import {
|
||||
} from '../../src/distributions/liberica/models';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/liberica.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -18,6 +20,10 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: manifestData as LibericaVersion[]
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -209,7 +215,7 @@ describe('findPackageForDownload', () => {
|
||||
|
||||
it('should throw an error', async () => {
|
||||
await expect(distribution['findPackageForDownload']('17')).rejects.toThrow(
|
||||
/Could not find satisfied version for semver */
|
||||
/No matching version found for SemVer/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,11 +5,13 @@ import {
|
||||
} from '../../src/distributions/liberica/models';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/liberica-linux.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -18,6 +20,10 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: manifestData as LibericaVersion[]
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -209,7 +215,7 @@ describe('findPackageForDownload', () => {
|
||||
|
||||
it('should throw an error', async () => {
|
||||
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
|
||||
/Could not find satisfied version for semver */
|
||||
/No matching version found for SemVer/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,11 +5,13 @@ import {
|
||||
} from '../../src/distributions/liberica/models';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/liberica-windows.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -18,6 +20,9 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: manifestData as LibericaVersion[]
|
||||
});
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -209,7 +214,7 @@ describe('findPackageForDownload', () => {
|
||||
|
||||
it('should throw an error', async () => {
|
||||
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
|
||||
/Could not find satisfied version for semver */
|
||||
/No matching version found for SemVer/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,6 +27,7 @@ describe('setupJava', () => {
|
||||
let spyFsReadDir: jest.SpyInstance;
|
||||
let spyUtilsExtractJdkFile: jest.SpyInstance;
|
||||
let spyPathResolve: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
const expectedJdkFile = 'JavaLocalJdkFile';
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -93,6 +94,10 @@ describe('setupJava', () => {
|
||||
// Spy on path methods
|
||||
spyPathResolve = jest.spyOn(path, 'resolve');
|
||||
spyPathResolve.mockImplementation((path: string) => path);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -8,6 +8,7 @@ describe('findPackageForDownload', () => {
|
||||
let distribution: MicrosoftDistributions;
|
||||
let spyGetManifestFromRepo: jest.SpyInstance;
|
||||
let spyDebug: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new MicrosoftDistributions({
|
||||
@@ -26,6 +27,10 @@ describe('findPackageForDownload', () => {
|
||||
|
||||
spyDebug = jest.spyOn(core, 'debug');
|
||||
spyDebug.mockImplementation(() => {});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -174,7 +179,7 @@ describe('findPackageForDownload', () => {
|
||||
|
||||
it('should throw an error', async () => {
|
||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ describe('findPackageForDownload', () => {
|
||||
let distribution: OracleDistribution;
|
||||
let spyDebug: jest.SpyInstance;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new OracleDistribution({
|
||||
@@ -19,6 +20,10 @@ describe('findPackageForDownload', () => {
|
||||
|
||||
spyDebug = jest.spyOn(core, 'debug');
|
||||
spyDebug.mockImplementation(() => {});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import {SapMachineDistribution} from '../../src/distributions/sapmachine/installer';
|
||||
import * as utils from '../../src/util';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/sapmachine.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -21,6 +23,10 @@ describe('getAvailableVersions', () => {
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -266,7 +272,7 @@ describe('getAvailableVersions', () => {
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](normalizedVersion)
|
||||
).rejects.toThrow(
|
||||
`Couldn't find any satisfied version for the specified java-version: "${normalizedVersion}" and architecture: "${arch}".`
|
||||
`No matching version found for SemVer '${normalizedVersion}'`
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -4,9 +4,11 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import {SemeruDistribution} from '../../src/distributions/semeru/installer';
|
||||
|
||||
import manifestData from '../data/semeru.json';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -15,6 +17,9 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -152,7 +157,7 @@ describe('findPackageForDownload', () => {
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
await expect(
|
||||
distribution['findPackageForDownload']('9.0.8')
|
||||
).rejects.toThrow(/Could not find satisfied version for SemVer */);
|
||||
).rejects.toThrow(/No matching version found for SemVer */);
|
||||
});
|
||||
|
||||
it('version is not found', async () => {
|
||||
@@ -164,7 +169,7 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
|
||||
@@ -177,7 +182,7 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
distribution['getAvailableVersions'] = async () => [];
|
||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -7,9 +7,11 @@ import {
|
||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
|
||||
import manifestData from '../data/temurin.json';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -18,6 +20,9 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -213,7 +218,7 @@ describe('findPackageForDownload', () => {
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
await expect(
|
||||
distribution['findPackageForDownload']('9.0.8')
|
||||
).rejects.toThrow(/Could not find satisfied version for SemVer */);
|
||||
).rejects.toThrow(/No matching version found for SemVer */);
|
||||
});
|
||||
|
||||
it('version is not found', async () => {
|
||||
@@ -228,7 +233,7 @@ describe('findPackageForDownload', () => {
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
|
||||
@@ -244,7 +249,7 @@ describe('findPackageForDownload', () => {
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => [];
|
||||
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||
/Could not find satisfied version for SemVer */
|
||||
/No matching version found for SemVer */
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,12 +3,14 @@ import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
||||
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||
import * as utils from '../../src/util';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/zulu-releases-default.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -23,6 +25,10 @@ describe('getAvailableVersions', () => {
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -225,6 +231,6 @@ describe('findPackageForDownload', () => {
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](distribution['version'])
|
||||
).rejects.toThrow(/Could not find satisfied version for semver */);
|
||||
).rejects.toThrow(/No matching version found for SemVer/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,12 +4,14 @@ import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
||||
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||
import * as utils from '../../src/util';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/zulu-linux.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -24,6 +26,10 @@ describe('getAvailableVersions', () => {
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -228,6 +234,6 @@ describe('findPackageForDownload', () => {
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](distribution['version'])
|
||||
).rejects.toThrow(/Could not find satisfied version for semver */);
|
||||
).rejects.toThrow(/No matching version found for SemVer/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,12 +4,14 @@ import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
||||
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||
import * as utils from '../../src/util';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/zulu-windows.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -24,6 +26,10 @@ describe('getAvailableVersions', () => {
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -226,6 +232,6 @@ describe('findPackageForDownload', () => {
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
await expect(
|
||||
distribution['findPackageForDownload'](distribution['version'])
|
||||
).rejects.toThrow(/Could not find satisfied version for semver */);
|
||||
).rejects.toThrow(/No matching version found for SemVer/);
|
||||
});
|
||||
});
|
||||
|
||||
111
dist/setup/index.js
vendored
111
dist/setup/index.js
vendored
@@ -77597,13 +77597,8 @@ class AdoptDistribution extends base_installer_1.JavaBase {
|
||||
});
|
||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersionsWithBinaries
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(`Could not find satisfied version for SemVer '${version}'. ${availableOptionsMessage}`);
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
return resolvedFullVersion;
|
||||
});
|
||||
@@ -77952,6 +77947,28 @@ class JavaBase {
|
||||
stable
|
||||
};
|
||||
}
|
||||
createVersionNotFoundError(versionOrRange, availableVersions, additionalContext) {
|
||||
const parts = [
|
||||
`No matching version found for SemVer '${versionOrRange}'.`,
|
||||
`Distribution: ${this.distribution}`,
|
||||
`Package type: ${this.packageType}`,
|
||||
`Architecture: ${this.architecture}`
|
||||
];
|
||||
// Add additional context if provided (e.g., platform/OS info)
|
||||
if (additionalContext) {
|
||||
parts.push(additionalContext);
|
||||
}
|
||||
if (availableVersions && availableVersions.length > 0) {
|
||||
const maxVersionsToShow = core.isDebug() ? availableVersions.length : 50;
|
||||
const versionsToShow = availableVersions.slice(0, maxVersionsToShow);
|
||||
const truncated = availableVersions.length > maxVersionsToShow;
|
||||
parts.push(`Available versions: ${versionsToShow.join(', ')}${truncated ? ', ...' : ''}`);
|
||||
if (truncated) {
|
||||
parts.push(`(showing first ${maxVersionsToShow} of ${availableVersions.length} versions, enable debug mode to see all)`);
|
||||
}
|
||||
}
|
||||
return new Error(parts.join('\n'));
|
||||
}
|
||||
setJavaDefault(version, toolPath) {
|
||||
const majorVersion = version.split('.')[0];
|
||||
core.exportVariable('JAVA_HOME', toolPath);
|
||||
@@ -78073,13 +78090,8 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
|
||||
});
|
||||
const resolvedVersion = matchingVersions.length > 0 ? matchingVersions[0] : null;
|
||||
if (!resolvedVersion) {
|
||||
const availableOptions = availableVersions
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(`Could not find satisfied version for SemVer '${version}'. ${availableOptionsMessage}`);
|
||||
const availableVersionStrings = availableVersions.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
return resolvedVersion;
|
||||
});
|
||||
@@ -78313,7 +78325,8 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||
};
|
||||
});
|
||||
if (!matchedVersions.length) {
|
||||
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`);
|
||||
const availableVersionStrings = availableVersions.map(item => item.jdk_version);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
const resolvedVersion = matchedVersions[0];
|
||||
return resolvedVersion;
|
||||
@@ -78504,6 +78517,7 @@ const base_installer_1 = __nccwpck_require__(59741);
|
||||
const http_client_1 = __nccwpck_require__(96255);
|
||||
const util_1 = __nccwpck_require__(92629);
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||
const GRAALVM_MIN_VERSION = 17;
|
||||
@@ -78582,7 +78596,10 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
handleHttpResponse(response, range) {
|
||||
const statusCode = response.message.statusCode;
|
||||
if (statusCode === http_client_1.HttpCodes.NotFound) {
|
||||
throw new Error(`Could not find GraalVM for SemVer ${range}. Please check if this version is available at ${GRAALVM_DL_BASE}`);
|
||||
// Create the standard error with additional hint about checking the download URL
|
||||
const error = this.createVersionNotFoundError(range);
|
||||
error.message += `\nPlease check if this version is available at ${GRAALVM_DOWNLOAD_URL} . Pick a version from the list.`;
|
||||
throw error;
|
||||
}
|
||||
if (statusCode === http_client_1.HttpCodes.Unauthorized ||
|
||||
statusCode === http_client_1.HttpCodes.Forbidden) {
|
||||
@@ -78599,8 +78616,8 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
||||
core.debug(`Found ${versions.length} EA versions`);
|
||||
const latestVersion = versions.find(v => v.latest);
|
||||
if (!latestVersion) {
|
||||
core.error(`Available versions: ${versions.map(v => v.version).join(', ')}`);
|
||||
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
||||
const availableVersions = versions.map(v => v.version);
|
||||
throw this.createVersionNotFoundError(javaEaVersion, availableVersions, 'Note: No EA build is marked as latest for this version.');
|
||||
}
|
||||
core.debug(`Latest version found: ${latestVersion.version}`);
|
||||
const arch = this.distributionArchitecture();
|
||||
@@ -78736,13 +78753,8 @@ class JetBrainsDistribution extends base_installer_1.JavaBase {
|
||||
});
|
||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = versionsRaw
|
||||
.map(item => `${item.tag_name} (${item.semver}+${item.build})`)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(`Could not find satisfied version for SemVer '${range}'. ${availableOptionsMessage}`);
|
||||
const availableVersionStrings = versionsRaw.map(item => `${item.tag_name} (${item.semver}+${item.build})`);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
return resolvedFullVersion;
|
||||
});
|
||||
@@ -78979,13 +78991,8 @@ class LibericaDistributions extends base_installer_1.JavaBase {
|
||||
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
|
||||
.sort((a, b) => -semver_1.default.compareBuild(a.version, b.version))[0];
|
||||
if (!satisfiedVersion) {
|
||||
const availableOptions = availableVersions
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(`Could not find satisfied version for semver ${range}. ${availableOptionsMessage}`);
|
||||
const availableVersionStrings = availableVersions.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
return satisfiedVersion;
|
||||
});
|
||||
@@ -79271,9 +79278,8 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||
}
|
||||
const foundRelease = yield tc.findFromManifest(range, true, manifest, arch);
|
||||
if (!foundRelease) {
|
||||
throw new Error(`Could not find satisfied version for SemVer ${range}.\nAvailable versions: ${manifest
|
||||
.map(item => item.version)
|
||||
.join(', ')}`);
|
||||
const availableVersionStrings = manifest.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
return {
|
||||
url: foundRelease.files[0].download_url,
|
||||
@@ -79436,7 +79442,7 @@ class OracleDistribution extends base_installer_1.JavaBase {
|
||||
throw new Error(`Http request for Oracle JDK failed with status code: ${response.message.statusCode}`);
|
||||
}
|
||||
}
|
||||
throw new Error(`Could not find Oracle JDK for SemVer ${range}`);
|
||||
throw this.createVersionNotFoundError(range);
|
||||
});
|
||||
}
|
||||
getPlatform(platform = process.platform) {
|
||||
@@ -79528,7 +79534,8 @@ class SapMachineDistribution extends base_installer_1.JavaBase {
|
||||
};
|
||||
});
|
||||
if (!matchedVersions.length) {
|
||||
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`);
|
||||
const availableVersionStrings = availableVersions.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
const resolvedVersion = matchedVersions[0];
|
||||
return resolvedVersion;
|
||||
@@ -79767,13 +79774,11 @@ class SemeruDistribution extends base_installer_1.JavaBase {
|
||||
});
|
||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersionsWithBinaries
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(`Could not find satisfied version for SemVer version '${version}' for your current OS version for ${this.architecture} architecture ${availableOptionsMessage}`);
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(item => item.version);
|
||||
// Include platform context to help users understand OS-specific version availability
|
||||
// IBM Semeru builds are OS-specific, so platform info aids in troubleshooting
|
||||
const platformContext = `Platform: ${process.platform}`;
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings, platformContext);
|
||||
}
|
||||
return resolvedFullVersion;
|
||||
});
|
||||
@@ -79946,13 +79951,8 @@ class TemurinDistribution extends base_installer_1.JavaBase {
|
||||
});
|
||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersionsWithBinaries
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(`Could not find satisfied version for SemVer '${version}'. ${availableOptionsMessage}`);
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
return resolvedFullVersion;
|
||||
});
|
||||
@@ -80124,13 +80124,8 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
||||
});
|
||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersions
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(`Could not find satisfied version for semver ${version}. ${availableOptionsMessage}`);
|
||||
const availableVersionStrings = availableVersions.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
return resolvedFullVersion;
|
||||
});
|
||||
|
||||
@@ -54,15 +54,10 @@ export class AdoptDistribution extends JavaBase {
|
||||
const resolvedFullVersion =
|
||||
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersionsWithBinaries
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(
|
||||
`Could not find satisfied version for SemVer '${version}'. ${availableOptionsMessage}`
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
|
||||
return resolvedFullVersion;
|
||||
|
||||
@@ -259,6 +259,42 @@ export abstract class JavaBase {
|
||||
};
|
||||
}
|
||||
|
||||
protected createVersionNotFoundError(
|
||||
versionOrRange: string,
|
||||
availableVersions?: string[],
|
||||
additionalContext?: string
|
||||
): Error {
|
||||
const parts = [
|
||||
`No matching version found for SemVer '${versionOrRange}'.`,
|
||||
`Distribution: ${this.distribution}`,
|
||||
`Package type: ${this.packageType}`,
|
||||
`Architecture: ${this.architecture}`
|
||||
];
|
||||
|
||||
// Add additional context if provided (e.g., platform/OS info)
|
||||
if (additionalContext) {
|
||||
parts.push(additionalContext);
|
||||
}
|
||||
|
||||
if (availableVersions && availableVersions.length > 0) {
|
||||
const maxVersionsToShow = core.isDebug() ? availableVersions.length : 50;
|
||||
const versionsToShow = availableVersions.slice(0, maxVersionsToShow);
|
||||
const truncated = availableVersions.length > maxVersionsToShow;
|
||||
|
||||
parts.push(
|
||||
`Available versions: ${versionsToShow.join(', ')}${truncated ? ', ...' : ''}`
|
||||
);
|
||||
|
||||
if (truncated) {
|
||||
parts.push(
|
||||
`(showing first ${maxVersionsToShow} of ${availableVersions.length} versions, enable debug mode to see all)`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return new Error(parts.join('\n'));
|
||||
}
|
||||
|
||||
protected setJavaDefault(version: string, toolPath: string) {
|
||||
const majorVersion = version.split('.')[0];
|
||||
core.exportVariable('JAVA_HOME', toolPath);
|
||||
|
||||
@@ -75,15 +75,10 @@ export class CorrettoDistribution extends JavaBase {
|
||||
const resolvedVersion =
|
||||
matchingVersions.length > 0 ? matchingVersions[0] : null;
|
||||
if (!resolvedVersion) {
|
||||
const availableOptions = availableVersions
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(
|
||||
`Could not find satisfied version for SemVer '${version}'. ${availableOptionsMessage}`
|
||||
const availableVersionStrings = availableVersions.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
return resolvedVersion;
|
||||
}
|
||||
|
||||
@@ -51,9 +51,10 @@ export class DragonwellDistribution extends JavaBase {
|
||||
});
|
||||
|
||||
if (!matchedVersions.length) {
|
||||
throw new Error(
|
||||
`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`
|
||||
const availableVersionStrings = availableVersions.map(
|
||||
item => item.jdk_version
|
||||
);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
|
||||
const resolvedVersion = matchedVersions[0];
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from '../../util';
|
||||
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const GRAALVM_PLATFORM = IS_WINDOWS ? 'windows' : process.platform;
|
||||
const GRAALVM_MIN_VERSION = 17;
|
||||
@@ -149,9 +150,10 @@ export class GraalVMDistribution extends JavaBase {
|
||||
const statusCode = response.message.statusCode;
|
||||
|
||||
if (statusCode === HttpCodes.NotFound) {
|
||||
throw new Error(
|
||||
`Could not find GraalVM for SemVer ${range}. Please check if this version is available at ${GRAALVM_DL_BASE}`
|
||||
);
|
||||
// Create the standard error with additional hint about checking the download URL
|
||||
const error = this.createVersionNotFoundError(range);
|
||||
error.message += `\nPlease check if this version is available at ${GRAALVM_DOWNLOAD_URL} . Pick a version from the list.`;
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -180,10 +182,12 @@ export class GraalVMDistribution extends JavaBase {
|
||||
|
||||
const latestVersion = versions.find(v => v.latest);
|
||||
if (!latestVersion) {
|
||||
core.error(
|
||||
`Available versions: ${versions.map(v => v.version).join(', ')}`
|
||||
const availableVersions = versions.map(v => v.version);
|
||||
throw this.createVersionNotFoundError(
|
||||
javaEaVersion,
|
||||
availableVersions,
|
||||
'Note: No EA build is marked as latest for this version.'
|
||||
);
|
||||
throw new Error(`Unable to find latest version for '${javaEaVersion}'`);
|
||||
}
|
||||
|
||||
core.debug(`Latest version found: ${latestVersion.version}`);
|
||||
|
||||
@@ -44,15 +44,10 @@ export class JetBrainsDistribution extends JavaBase {
|
||||
const resolvedFullVersion =
|
||||
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = versionsRaw
|
||||
.map(item => `${item.tag_name} (${item.semver}+${item.build})`)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(
|
||||
`Could not find satisfied version for SemVer '${range}'. ${availableOptionsMessage}`
|
||||
const availableVersionStrings = versionsRaw.map(
|
||||
item => `${item.tag_name} (${item.semver}+${item.build})`
|
||||
);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
|
||||
return resolvedFullVersion;
|
||||
|
||||
@@ -69,15 +69,10 @@ export class LibericaDistributions extends JavaBase {
|
||||
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
|
||||
|
||||
if (!satisfiedVersion) {
|
||||
const availableOptions = availableVersions
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(
|
||||
`Could not find satisfied version for semver ${range}. ${availableOptionsMessage}`
|
||||
const availableVersionStrings = availableVersions.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
|
||||
return satisfiedVersion;
|
||||
|
||||
@@ -76,11 +76,8 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
const foundRelease = await tc.findFromManifest(range, true, manifest, arch);
|
||||
|
||||
if (!foundRelease) {
|
||||
throw new Error(
|
||||
`Could not find satisfied version for SemVer ${range}.\nAvailable versions: ${manifest
|
||||
.map(item => item.version)
|
||||
.join(', ')}`
|
||||
);
|
||||
const availableVersionStrings = manifest.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -112,7 +112,7 @@ export class OracleDistribution extends JavaBase {
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Could not find Oracle JDK for SemVer ${range}`);
|
||||
throw this.createVersionNotFoundError(range);
|
||||
}
|
||||
|
||||
public getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
||||
|
||||
@@ -49,9 +49,10 @@ export class SapMachineDistribution extends JavaBase {
|
||||
});
|
||||
|
||||
if (!matchedVersions.length) {
|
||||
throw new Error(
|
||||
`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`
|
||||
const availableVersionStrings = availableVersions.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
|
||||
const resolvedVersion = matchedVersions[0];
|
||||
|
||||
@@ -79,14 +79,16 @@ export class SemeruDistribution extends JavaBase {
|
||||
const resolvedFullVersion =
|
||||
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersionsWithBinaries
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(
|
||||
`Could not find satisfied version for SemVer version '${version}' for your current OS version for ${this.architecture} architecture ${availableOptionsMessage}`
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(
|
||||
item => item.version
|
||||
);
|
||||
// Include platform context to help users understand OS-specific version availability
|
||||
// IBM Semeru builds are OS-specific, so platform info aids in troubleshooting
|
||||
const platformContext = `Platform: ${process.platform}`;
|
||||
throw this.createVersionNotFoundError(
|
||||
version,
|
||||
availableVersionStrings,
|
||||
platformContext
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,15 +57,10 @@ export class TemurinDistribution extends JavaBase {
|
||||
const resolvedFullVersion =
|
||||
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersionsWithBinaries
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(
|
||||
`Could not find satisfied version for SemVer '${version}'. ${availableOptionsMessage}`
|
||||
const availableVersionStrings = availableVersionsWithBinaries.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
|
||||
return resolvedFullVersion;
|
||||
|
||||
@@ -57,15 +57,10 @@ export class ZuluDistribution extends JavaBase {
|
||||
const resolvedFullVersion =
|
||||
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||
if (!resolvedFullVersion) {
|
||||
const availableOptions = availableVersions
|
||||
.map(item => item.version)
|
||||
.join(', ');
|
||||
const availableOptionsMessage = availableOptions
|
||||
? `\nAvailable versions: ${availableOptions}`
|
||||
: '';
|
||||
throw new Error(
|
||||
`Could not find satisfied version for semver ${version}. ${availableOptionsMessage}`
|
||||
const availableVersionStrings = availableVersions.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||
}
|
||||
|
||||
return resolvedFullVersion;
|
||||
|
||||
Reference in New Issue
Block a user