From 81bfa641b0c417daf5f8da7106cd29e6f422d1a9 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 17 Jun 2020 17:42:32 +0200 Subject: [PATCH 1/3] Normalize extendedJavaHome environment variable The extendedJavaHome environment variable contains `.` symbols in the version. This causes the environment variable to be ignored by the action runner. It's best to replace those and other non standard symbols with and underscore. For reference: > Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set . --- dist/index.js | 1 + src/installer.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/index.js b/dist/index.js index 2634606..36a56bb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4742,6 +4742,7 @@ function getJava(version, arch, jdkFile, javaPackage) { toolPath = yield tc.cacheDir(jdkDir, javaPackage, getCacheVersionString(version), arch); } let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch; + extendedJavaHome = extendedJavaHome.toUpperCase().replace(/[^0-9A-Z_]/g, '_'); core.exportVariable('JAVA_HOME', toolPath); core.exportVariable(extendedJavaHome, toolPath); core.addPath(path.join(toolPath, 'bin')); diff --git a/src/installer.ts b/src/installer.ts index 487db6f..7a8feae 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -87,6 +87,7 @@ export async function getJava( } let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch; + extendedJavaHome = extendedJavaHome.toUpperCase().replace(/[^0-9A-Z_]/g, '_'); core.exportVariable('JAVA_HOME', toolPath); core.exportVariable(extendedJavaHome, toolPath); core.addPath(path.join(toolPath, 'bin')); From 655cb05195987cc98509c9d014293425433f2676 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 17 Jun 2020 19:37:01 +0200 Subject: [PATCH 2/3] Add comment explaining why the environment variable should be normalized --- dist/index.js | 4 ++++ src/installer.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/dist/index.js b/dist/index.js index 36a56bb..aed138a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4742,6 +4742,10 @@ function getJava(version, arch, jdkFile, javaPackage) { toolPath = yield tc.cacheDir(jdkDir, javaPackage, getCacheVersionString(version), arch); } let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch; + // For portability reasons environment variables should only consist of + // uppercase letters, digits, and the underscore. Therefore we convert + // the extendedJavaHome variable to upper case and replace '.' symbols and + // any other non-alphanumeric characters with an underscore. extendedJavaHome = extendedJavaHome.toUpperCase().replace(/[^0-9A-Z_]/g, '_'); core.exportVariable('JAVA_HOME', toolPath); core.exportVariable(extendedJavaHome, toolPath); diff --git a/src/installer.ts b/src/installer.ts index 7a8feae..29b0d89 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -87,6 +87,10 @@ export async function getJava( } let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch; + // For portability reasons environment variables should only consist of + // uppercase letters, digits, and the underscore. Therefore we convert + // the extendedJavaHome variable to upper case and replace '.' symbols and + // any other non-alphanumeric characters with an underscore. extendedJavaHome = extendedJavaHome.toUpperCase().replace(/[^0-9A-Z_]/g, '_'); core.exportVariable('JAVA_HOME', toolPath); core.exportVariable(extendedJavaHome, toolPath); From 88965601fb401f72b12f9694e7e9ccd747f67888 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 17 Jun 2020 21:37:10 +0200 Subject: [PATCH 3/3] Keep old environment variable for backwards compatibility --- dist/index.js | 1 + src/installer.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/index.js b/dist/index.js index aed138a..d77e3be 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4742,6 +4742,7 @@ function getJava(version, arch, jdkFile, javaPackage) { toolPath = yield tc.cacheDir(jdkDir, javaPackage, getCacheVersionString(version), arch); } let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch; + core.exportVariable(extendedJavaHome, toolPath); //TODO: remove for v2 // For portability reasons environment variables should only consist of // uppercase letters, digits, and the underscore. Therefore we convert // the extendedJavaHome variable to upper case and replace '.' symbols and diff --git a/src/installer.ts b/src/installer.ts index 29b0d89..ba70611 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -87,6 +87,7 @@ export async function getJava( } let extendedJavaHome = 'JAVA_HOME_' + version + '_' + arch; + core.exportVariable(extendedJavaHome, toolPath); //TODO: remove for v2 // For portability reasons environment variables should only consist of // uppercase letters, digits, and the underscore. Therefore we convert // the extendedJavaHome variable to upper case and replace '.' symbols and