mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 10:26:46 +00:00
Avoid "+" sign in Java path in v2-preview (#145)
* try to handle _ versions * more logs * more debug * test 1 * more fixes * fix typo * Update e2e-versions.yml * add unit-tests * remove debug info from tests * debug pre-cached versions * change e2e tests to ubuntu-latest
This commit is contained in:
parent
022e86d5c9
commit
46d5f06eb1
5 changed files with 110 additions and 50 deletions
46
dist/setup/index.js
vendored
46
dist/setup/index.js
vendored
|
@ -3970,7 +3970,6 @@ class JavaBase {
|
|||
this.checkLatest = installerOptions.checkLatest;
|
||||
}
|
||||
setupJava() {
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let foundJava = this.findInToolcache();
|
||||
if (foundJava && !this.checkLatest) {
|
||||
|
@ -3980,8 +3979,6 @@ class JavaBase {
|
|||
core.info('Trying to resolve the latest version from remote');
|
||||
const javaRelease = yield this.findPackageForDownload(this.version);
|
||||
core.info(`Resolved latest version as ${javaRelease.version}`);
|
||||
core.info((_a = foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) !== null && _a !== void 0 ? _a : '');
|
||||
core.info((_b = javaRelease.version) !== null && _b !== void 0 ? _b : '');
|
||||
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) {
|
||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
}
|
||||
|
@ -4006,30 +4003,49 @@ class JavaBase {
|
|||
}
|
||||
getToolcacheVersionName(version) {
|
||||
if (!this.stable) {
|
||||
const cleanVersion = semver_1.default.clean(version);
|
||||
return `${cleanVersion}-ea`;
|
||||
if (version.includes('+')) {
|
||||
return version.replace('+', '-ea.');
|
||||
}
|
||||
else {
|
||||
return `${version}-ea`;
|
||||
}
|
||||
}
|
||||
return version;
|
||||
// Kotlin and some Java dependencies don't work properly when Java path contains "+" sign
|
||||
// so replace "/hostedtoolcache/Java/11.0.3+4/x64" to "/hostedtoolcache/Java/11.0.3-4/x64" when saves to cache
|
||||
// related issue: https://github.com/actions/virtual-environments/issues/3014
|
||||
return version.replace('+', '-');
|
||||
}
|
||||
findInToolcache() {
|
||||
// we can't use tc.find directly because firstly, we need to filter versions by stability flag
|
||||
// if *-ea is provided, take only ea versions from toolcache, otherwise - only stable versions
|
||||
const availableVersions = tc
|
||||
.findAllVersions(this.toolcacheFolderName, this.architecture)
|
||||
.filter(item => item.endsWith('-ea') === !this.stable);
|
||||
.map(item => {
|
||||
return {
|
||||
version: item
|
||||
.replace('-ea.', '+')
|
||||
.replace(/-ea$/, '')
|
||||
// Kotlin and some Java dependencies don't work properly when Java path contains "+" sign
|
||||
// so replace "/hostedtoolcache/Java/11.0.3-4/x64" to "/hostedtoolcache/Java/11.0.3+4/x64" when retrieves to cache
|
||||
// related issue: https://github.com/actions/virtual-environments/issues/3014
|
||||
.replace('-', '+'),
|
||||
path: util_1.getToolcachePath(this.toolcacheFolderName, item, this.architecture) || '',
|
||||
stable: !item.includes('-ea')
|
||||
};
|
||||
})
|
||||
.filter(item => item.stable === this.stable);
|
||||
const satisfiedVersions = availableVersions
|
||||
.filter(item => util_1.isVersionSatisfies(this.version, item.replace(/-ea$/, '')))
|
||||
.sort(semver_1.default.rcompare);
|
||||
.filter(item => util_1.isVersionSatisfies(this.version, item.version))
|
||||
.filter(item => item.path)
|
||||
.sort((a, b) => {
|
||||
return -semver_1.default.compareBuild(a.version, b.version);
|
||||
});
|
||||
if (!satisfiedVersions || satisfiedVersions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const javaPath = util_1.getToolcachePath(this.toolcacheFolderName, satisfiedVersions[0], this.architecture);
|
||||
if (!javaPath) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
version: util_1.getVersionFromToolcachePath(javaPath),
|
||||
path: javaPath
|
||||
version: satisfiedVersions[0].version,
|
||||
path: satisfiedVersions[0].path
|
||||
};
|
||||
}
|
||||
normalizeVersion(version) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue