Compare commits
	
		
			5 Commits
		
	
	
		
			v3.11.0
			...
			tool-confi
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 0b13a57b75 | |||
| ddb82ce8a6 | |||
| 404e5db3a1 | |||
| 191ba8c6ba | |||
| e42168ca1a | 
@ -7,7 +7,7 @@ module.exports = {
 | 
				
			|||||||
    'eslint-config-prettier'
 | 
					    'eslint-config-prettier'
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  parser: '@typescript-eslint/parser',
 | 
					  parser: '@typescript-eslint/parser',
 | 
				
			||||||
  plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
 | 
					  plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
 | 
				
			||||||
  rules: {
 | 
					  rules: {
 | 
				
			||||||
    '@typescript-eslint/no-require-imports': 'error',
 | 
					    '@typescript-eslint/no-require-imports': 'error',
 | 
				
			||||||
    '@typescript-eslint/no-non-null-assertion': 'off',
 | 
					    '@typescript-eslint/no-non-null-assertion': 'off',
 | 
				
			||||||
@ -28,7 +28,8 @@ module.exports = {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    'no-control-regex': 'off',
 | 
					    'no-control-regex': 'off',
 | 
				
			||||||
    'no-constant-condition': ['error', {checkLoops: false}]
 | 
					    'no-constant-condition': ['error', {checkLoops: false}],
 | 
				
			||||||
 | 
					    'node/no-extraneous-import': 'error'
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  overrides: [
 | 
					  overrides: [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
@ -116,7 +116,7 @@ Currently, the following distributions are supported:
 | 
				
			|||||||
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/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:
 | 
					The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/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:
 | 
				
			||||||
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, and `gradle/*.versions.toml`
 | 
					- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, and `gradle/*.versions.toml`
 | 
				
			||||||
- maven: `**/pom.xml`
 | 
					- maven: `**/pom.xml`
 | 
				
			||||||
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.{scala,sbt}`
 | 
					- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The workflow output `cache-hit` is set to indicate if an exact match was found for the key [as actions/cache does](https://github.com/actions/cache/tree/main#outputs).
 | 
					The workflow output `cache-hit` is set to indicate if an exact match was found for the key [as actions/cache does](https://github.com/actions/cache/tree/main#outputs).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -145,7 +145,7 @@ describe('dependency cache', () => {
 | 
				
			|||||||
        await expect(restore('sbt')).rejects.toThrow(
 | 
					        await expect(restore('sbt')).rejects.toThrow(
 | 
				
			||||||
          `No file in ${projectRoot(
 | 
					          `No file in ${projectRoot(
 | 
				
			||||||
            workspace
 | 
					            workspace
 | 
				
			||||||
          )} matched to [**/*.sbt,**/project/build.properties,**/project/**.{scala,sbt}], make sure you have checked out the target repository`
 | 
					          )} matched to [**/*.sbt,**/project/build.properties,**/project/**.scala,**/project/**.sbt], make sure you have checked out the target repository`
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      it('downloads cache', async () => {
 | 
					      it('downloads cache', async () => {
 | 
				
			||||||
@ -156,6 +156,28 @@ describe('dependency cache', () => {
 | 
				
			|||||||
        expect(spyWarning).not.toHaveBeenCalled();
 | 
					        expect(spyWarning).not.toHaveBeenCalled();
 | 
				
			||||||
        expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found');
 | 
					        expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found');
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					      it('detects scala and sbt changes under **/project/ folder', async () => {
 | 
				
			||||||
 | 
					        createFile(join(workspace, 'build.sbt'));
 | 
				
			||||||
 | 
					        createDirectory(join(workspace, 'project'));
 | 
				
			||||||
 | 
					        createFile(join(workspace, 'project/DependenciesV1.scala'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await restore('sbt');
 | 
				
			||||||
 | 
					        const firstCall = spySaveState.mock.calls.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        spySaveState.mockClear();
 | 
				
			||||||
 | 
					        await restore('sbt');
 | 
				
			||||||
 | 
					        const secondCall = spySaveState.mock.calls.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Make sure multiple restores produce the same cache
 | 
				
			||||||
 | 
					        expect(firstCall).toBe(secondCall);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        spySaveState.mockClear();
 | 
				
			||||||
 | 
					        createFile(join(workspace, 'project/DependenciesV2.scala'));
 | 
				
			||||||
 | 
					        await restore('sbt');
 | 
				
			||||||
 | 
					        const thirdCall = spySaveState.mock.calls.toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        expect(firstCall).not.toBe(thirdCall);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
  describe('save', () => {
 | 
					  describe('save', () => {
 | 
				
			||||||
 | 
				
			|||||||
@ -214,6 +214,93 @@ describe('setupJava', () => {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('java is resolved from toolcache including Contents/Home on MacOS', async () => {
 | 
				
			||||||
 | 
					    const inputs = {
 | 
				
			||||||
 | 
					      version: actualJavaVersion,
 | 
				
			||||||
 | 
					      architecture: 'x86',
 | 
				
			||||||
 | 
					      packageType: 'jdk',
 | 
				
			||||||
 | 
					      checkLatest: false
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    const jdkFile = 'not_existing_one';
 | 
				
			||||||
 | 
					    const expected = {
 | 
				
			||||||
 | 
					      version: actualJavaVersion,
 | 
				
			||||||
 | 
					      path: path.join(
 | 
				
			||||||
 | 
					        'Java_jdkfile_jdk',
 | 
				
			||||||
 | 
					        inputs.version,
 | 
				
			||||||
 | 
					        inputs.architecture,
 | 
				
			||||||
 | 
					        'Contents',
 | 
				
			||||||
 | 
					        'Home'
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    const originalPlatform = process.platform;
 | 
				
			||||||
 | 
					    Object.defineProperty(process, 'platform', {
 | 
				
			||||||
 | 
					      value: 'darwin'
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    spyFsStat = jest.spyOn(fs, 'existsSync');
 | 
				
			||||||
 | 
					    spyFsStat.mockImplementation((file: string) => {
 | 
				
			||||||
 | 
					      return file.endsWith('Home');
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mockJavaBase = new LocalDistribution(inputs, jdkFile);
 | 
				
			||||||
 | 
					    await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
 | 
				
			||||||
 | 
					    expect(spyGetToolcachePath).toHaveBeenCalled();
 | 
				
			||||||
 | 
					    expect(spyCoreInfo).toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      `Resolved Java ${actualJavaVersion} from tool-cache`
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    expect(spyCoreInfo).not.toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Object.defineProperty(process, 'platform', {
 | 
				
			||||||
 | 
					      value: originalPlatform
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('java is unpacked from jdkfile including Contents/Home on MacOS', async () => {
 | 
				
			||||||
 | 
					    const inputs = {
 | 
				
			||||||
 | 
					      version: '11.0.289',
 | 
				
			||||||
 | 
					      architecture: 'x86',
 | 
				
			||||||
 | 
					      packageType: 'jdk',
 | 
				
			||||||
 | 
					      checkLatest: false
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    const jdkFile = expectedJdkFile;
 | 
				
			||||||
 | 
					    const expected = {
 | 
				
			||||||
 | 
					      version: '11.0.289',
 | 
				
			||||||
 | 
					      path: path.join(
 | 
				
			||||||
 | 
					        'Java_jdkfile_jdk',
 | 
				
			||||||
 | 
					        inputs.version,
 | 
				
			||||||
 | 
					        inputs.architecture,
 | 
				
			||||||
 | 
					        'Contents',
 | 
				
			||||||
 | 
					        'Home'
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    const originalPlatform = process.platform;
 | 
				
			||||||
 | 
					    Object.defineProperty(process, 'platform', {
 | 
				
			||||||
 | 
					      value: 'darwin'
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    spyFsStat = jest.spyOn(fs, 'existsSync');
 | 
				
			||||||
 | 
					    spyFsStat.mockImplementation((file: string) => {
 | 
				
			||||||
 | 
					      return file.endsWith('Home');
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mockJavaBase = new LocalDistribution(inputs, jdkFile);
 | 
				
			||||||
 | 
					    await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
 | 
				
			||||||
 | 
					    expect(spyTcFindAllVersions).toHaveBeenCalled();
 | 
				
			||||||
 | 
					    expect(spyCoreInfo).not.toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      `Resolved Java ${actualJavaVersion} from tool-cache`
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    expect(spyCoreInfo).toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      `Extracting Java from '${jdkFile}'`
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    expect(spyCoreInfo).toHaveBeenCalledWith(
 | 
				
			||||||
 | 
					      `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    Object.defineProperty(process, 'platform', {
 | 
				
			||||||
 | 
					      value: originalPlatform
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it.each([
 | 
					  it.each([
 | 
				
			||||||
    [
 | 
					    [
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
 | 
				
			|||||||
@ -227,22 +227,3 @@ describe('findPackageForDownload', () => {
 | 
				
			|||||||
    ).rejects.toThrow(/Could not find satisfied version for semver */);
 | 
					    ).rejects.toThrow(/Could not find satisfied version for semver */);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					 | 
				
			||||||
describe('convertVersionToSemver', () => {
 | 
					 | 
				
			||||||
  it.each([
 | 
					 | 
				
			||||||
    [[12], '12'],
 | 
					 | 
				
			||||||
    [[12, 0], '12.0'],
 | 
					 | 
				
			||||||
    [[12, 0, 2], '12.0.2'],
 | 
					 | 
				
			||||||
    [[12, 0, 2, 1], '12.0.2+1'],
 | 
					 | 
				
			||||||
    [[12, 0, 2, 1, 3], '12.0.2+1']
 | 
					 | 
				
			||||||
  ])('%s -> %s', (input: number[], expected: string) => {
 | 
					 | 
				
			||||||
    const distribution = new ZuluDistribution({
 | 
					 | 
				
			||||||
      version: '18',
 | 
					 | 
				
			||||||
      architecture: 'x86',
 | 
					 | 
				
			||||||
      packageType: 'jdk',
 | 
					 | 
				
			||||||
      checkLatest: false
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    const actual = distribution['convertVersionToSemver'](input);
 | 
					 | 
				
			||||||
    expect(actual).toBe(expected);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,10 @@
 | 
				
			|||||||
import * as cache from '@actions/cache';
 | 
					import * as cache from '@actions/cache';
 | 
				
			||||||
import * as core from '@actions/core';
 | 
					import * as core from '@actions/core';
 | 
				
			||||||
import {isVersionSatisfies, isCacheFeatureAvailable} from '../src/util';
 | 
					import {
 | 
				
			||||||
 | 
					  convertVersionToSemver,
 | 
				
			||||||
 | 
					  isVersionSatisfies,
 | 
				
			||||||
 | 
					  isCacheFeatureAvailable
 | 
				
			||||||
 | 
					} from '../src/util';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jest.mock('@actions/cache');
 | 
					jest.mock('@actions/cache');
 | 
				
			||||||
jest.mock('@actions/core');
 | 
					jest.mock('@actions/core');
 | 
				
			||||||
@ -63,3 +67,16 @@ describe('isCacheFeatureAvailable', () => {
 | 
				
			|||||||
    expect(isCacheFeatureAvailable()).toBe(true);
 | 
					    expect(isCacheFeatureAvailable()).toBe(true);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('convertVersionToSemver', () => {
 | 
				
			||||||
 | 
					  it.each([
 | 
				
			||||||
 | 
					    ['12', '12'],
 | 
				
			||||||
 | 
					    ['12.0', '12.0'],
 | 
				
			||||||
 | 
					    ['12.0.2', '12.0.2'],
 | 
				
			||||||
 | 
					    ['12.0.2.1', '12.0.2+1'],
 | 
				
			||||||
 | 
					    ['12.0.2.1.0', '12.0.2+1.0']
 | 
				
			||||||
 | 
					  ])('%s -> %s', (input: string, expected: string) => {
 | 
				
			||||||
 | 
					    const actual = convertVersionToSemver(input);
 | 
				
			||||||
 | 
					    expect(actual).toBe(expected);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								dist/cleanup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								dist/cleanup/index.js
									
									
									
									
										vendored
									
									
								
							@ -68416,7 +68416,8 @@ const supportedPackageManager = [
 | 
				
			|||||||
        pattern: [
 | 
					        pattern: [
 | 
				
			||||||
            '**/*.sbt',
 | 
					            '**/*.sbt',
 | 
				
			||||||
            '**/project/build.properties',
 | 
					            '**/project/build.properties',
 | 
				
			||||||
            '**/project/**.{scala,sbt}'
 | 
					            '**/project/**.scala',
 | 
				
			||||||
 | 
					            '**/project/**.sbt'
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
@ -68785,7 +68786,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
				
			|||||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
					    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
					Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
				
			||||||
exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
 | 
					exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
 | 
				
			||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
 | 
					const os_1 = __importDefault(__nccwpck_require__(2037));
 | 
				
			||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
					const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
				
			||||||
const fs = __importStar(__nccwpck_require__(7147));
 | 
					const fs = __importStar(__nccwpck_require__(7147));
 | 
				
			||||||
@ -68912,6 +68913,16 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
 | 
				
			|||||||
function avoidOldNotation(content) {
 | 
					function avoidOldNotation(content) {
 | 
				
			||||||
    return content.startsWith('1.') ? content.substring(2) : content;
 | 
					    return content.startsWith('1.') ? content.substring(2) : content;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					function convertVersionToSemver(version) {
 | 
				
			||||||
 | 
					    // Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
 | 
				
			||||||
 | 
					    const versionArray = Array.isArray(version) ? version : version.split('.');
 | 
				
			||||||
 | 
					    const mainVersion = versionArray.slice(0, 3).join('.');
 | 
				
			||||||
 | 
					    if (versionArray.length > 3) {
 | 
				
			||||||
 | 
					        return `${mainVersion}+${versionArray.slice(3).join('.')}`;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return mainVersion;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					exports.convertVersionToSemver = convertVersionToSemver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***/ }),
 | 
					/***/ }),
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										42
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										42
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -103621,7 +103621,8 @@ const supportedPackageManager = [
 | 
				
			|||||||
        pattern: [
 | 
					        pattern: [
 | 
				
			||||||
            '**/*.sbt',
 | 
					            '**/*.sbt',
 | 
				
			||||||
            '**/project/build.properties',
 | 
					            '**/project/build.properties',
 | 
				
			||||||
            '**/project/**.{scala,sbt}'
 | 
					            '**/project/**.scala',
 | 
				
			||||||
 | 
					            '**/project/**.sbt'
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
@ -104208,7 +104209,7 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
 | 
				
			|||||||
                .filter(item => item.version == version)
 | 
					                .filter(item => item.version == version)
 | 
				
			||||||
                .map(item => {
 | 
					                .map(item => {
 | 
				
			||||||
                return {
 | 
					                return {
 | 
				
			||||||
                    version: item.correttoVersion,
 | 
					                    version: util_1.convertVersionToSemver(item.correttoVersion),
 | 
				
			||||||
                    url: item.downloadLink
 | 
					                    url: item.downloadLink
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@ -104608,17 +104609,17 @@ class LocalDistribution extends base_installer_1.JavaBase {
 | 
				
			|||||||
                const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
 | 
					                const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
 | 
				
			||||||
                const archivePath = path_1.default.join(extractedJavaPath, archiveName);
 | 
					                const archivePath = path_1.default.join(extractedJavaPath, archiveName);
 | 
				
			||||||
                const javaVersion = this.version;
 | 
					                const javaVersion = this.version;
 | 
				
			||||||
                let javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaVersion), this.architecture);
 | 
					                const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaVersion), this.architecture);
 | 
				
			||||||
                // for different Java distributions, postfix can exist or not so need to check both cases
 | 
					 | 
				
			||||||
                if (process.platform === 'darwin' &&
 | 
					 | 
				
			||||||
                    fs_1.default.existsSync(path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX))) {
 | 
					 | 
				
			||||||
                    javaPath = path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                foundJava = {
 | 
					                foundJava = {
 | 
				
			||||||
                    version: javaVersion,
 | 
					                    version: javaVersion,
 | 
				
			||||||
                    path: javaPath
 | 
					                    path: javaPath
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            // JDK folder may contain postfix "Contents/Home" on macOS
 | 
				
			||||||
 | 
					            const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX);
 | 
				
			||||||
 | 
					            if (process.platform === 'darwin' && fs_1.default.existsSync(macOSPostfixPath)) {
 | 
				
			||||||
 | 
					                foundJava.path = macOSPostfixPath;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            core.info(`Setting Java ${foundJava.version} as default`);
 | 
					            core.info(`Setting Java ${foundJava.version} as default`);
 | 
				
			||||||
            this.setJavaDefault(foundJava.version, foundJava.path);
 | 
					            this.setJavaDefault(foundJava.version, foundJava.path);
 | 
				
			||||||
            return foundJava;
 | 
					            return foundJava;
 | 
				
			||||||
@ -105309,9 +105310,9 @@ class ZuluDistribution extends base_installer_1.JavaBase {
 | 
				
			|||||||
            const availableVersionsRaw = yield this.getAvailableVersions();
 | 
					            const availableVersionsRaw = yield this.getAvailableVersions();
 | 
				
			||||||
            const availableVersions = availableVersionsRaw.map(item => {
 | 
					            const availableVersions = availableVersionsRaw.map(item => {
 | 
				
			||||||
                return {
 | 
					                return {
 | 
				
			||||||
                    version: this.convertVersionToSemver(item.jdk_version),
 | 
					                    version: util_1.convertVersionToSemver(item.jdk_version),
 | 
				
			||||||
                    url: item.url,
 | 
					                    url: item.url,
 | 
				
			||||||
                    zuluVersion: this.convertVersionToSemver(item.zulu_version)
 | 
					                    zuluVersion: util_1.convertVersionToSemver(item.zulu_version)
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
            const satisfiedVersions = availableVersions
 | 
					            const satisfiedVersions = availableVersions
 | 
				
			||||||
@ -105418,15 +105419,6 @@ class ZuluDistribution extends base_installer_1.JavaBase {
 | 
				
			|||||||
                return process.platform;
 | 
					                return process.platform;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Azul API returns jdk_version as array of digits like [11, 0, 2, 1]
 | 
					 | 
				
			||||||
    convertVersionToSemver(version_array) {
 | 
					 | 
				
			||||||
        const mainVersion = version_array.slice(0, 3).join('.');
 | 
					 | 
				
			||||||
        if (version_array.length > 3) {
 | 
					 | 
				
			||||||
            // intentionally ignore more than 4 numbers because it is invalid semver
 | 
					 | 
				
			||||||
            return `${mainVersion}+${version_array[3]}`;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return mainVersion;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.ZuluDistribution = ZuluDistribution;
 | 
					exports.ZuluDistribution = ZuluDistribution;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -105842,7 +105834,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
				
			|||||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
					    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
					Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
				
			||||||
exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
 | 
					exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
 | 
				
			||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
 | 
					const os_1 = __importDefault(__nccwpck_require__(2037));
 | 
				
			||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
					const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
				
			||||||
const fs = __importStar(__nccwpck_require__(7147));
 | 
					const fs = __importStar(__nccwpck_require__(7147));
 | 
				
			||||||
@ -105969,6 +105961,16 @@ exports.getVersionFromFileContent = getVersionFromFileContent;
 | 
				
			|||||||
function avoidOldNotation(content) {
 | 
					function avoidOldNotation(content) {
 | 
				
			||||||
    return content.startsWith('1.') ? content.substring(2) : content;
 | 
					    return content.startsWith('1.') ? content.substring(2) : content;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					function convertVersionToSemver(version) {
 | 
				
			||||||
 | 
					    // Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
 | 
				
			||||||
 | 
					    const versionArray = Array.isArray(version) ? version : version.split('.');
 | 
				
			||||||
 | 
					    const mainVersion = versionArray.slice(0, 3).join('.');
 | 
				
			||||||
 | 
					    if (versionArray.length > 3) {
 | 
				
			||||||
 | 
					        return `${mainVersion}+${versionArray.slice(3).join('.')}`;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return mainVersion;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					exports.convertVersionToSemver = convertVersionToSemver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***/ }),
 | 
					/***/ }),
 | 
				
			||||||
 | 
				
			|||||||
@ -6,10 +6,10 @@
 | 
				
			|||||||
  "main": "dist/setup/index.js",
 | 
					  "main": "dist/setup/index.js",
 | 
				
			||||||
  "scripts": {
 | 
					  "scripts": {
 | 
				
			||||||
    "build": "ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts",
 | 
					    "build": "ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts",
 | 
				
			||||||
    "format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write **/*.{ts,yml,yaml}",
 | 
					    "format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"",
 | 
				
			||||||
    "format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check **/*.{ts,yml,yaml}",
 | 
					    "format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"",
 | 
				
			||||||
    "lint": "eslint --config ./.eslintrc.js **/*.ts",
 | 
					    "lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
 | 
				
			||||||
    "lint:fix": "eslint --config ./.eslintrc.js **/*.ts --fix",
 | 
					    "lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix",
 | 
				
			||||||
    "prerelease": "npm run-script build",
 | 
					    "prerelease": "npm run-script build",
 | 
				
			||||||
    "release": "git add -f dist/setup/index.js dist/cleanup/index.js",
 | 
					    "release": "git add -f dist/setup/index.js dist/cleanup/index.js",
 | 
				
			||||||
    "test": "jest"
 | 
					    "test": "jest"
 | 
				
			||||||
 | 
				
			|||||||
@ -56,7 +56,8 @@ const supportedPackageManager: PackageManager[] = [
 | 
				
			|||||||
    pattern: [
 | 
					    pattern: [
 | 
				
			||||||
      '**/*.sbt',
 | 
					      '**/*.sbt',
 | 
				
			||||||
      '**/project/build.properties',
 | 
					      '**/project/build.properties',
 | 
				
			||||||
      '**/project/**.{scala,sbt}'
 | 
					      '**/project/**.scala',
 | 
				
			||||||
 | 
					      '**/project/**.sbt'
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,11 @@ import * as core from '@actions/core';
 | 
				
			|||||||
import * as tc from '@actions/tool-cache';
 | 
					import * as tc from '@actions/tool-cache';
 | 
				
			||||||
import fs from 'fs';
 | 
					import fs from 'fs';
 | 
				
			||||||
import path from 'path';
 | 
					import path from 'path';
 | 
				
			||||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
 | 
					import {
 | 
				
			||||||
 | 
					  extractJdkFile,
 | 
				
			||||||
 | 
					  getDownloadArchiveExtension,
 | 
				
			||||||
 | 
					  convertVersionToSemver
 | 
				
			||||||
 | 
					} from '../../util';
 | 
				
			||||||
import {JavaBase} from '../base-installer';
 | 
					import {JavaBase} from '../base-installer';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  JavaDownloadRelease,
 | 
					  JavaDownloadRelease,
 | 
				
			||||||
@ -62,7 +66,7 @@ export class CorrettoDistribution extends JavaBase {
 | 
				
			|||||||
      .filter(item => item.version == version)
 | 
					      .filter(item => item.version == version)
 | 
				
			||||||
      .map(item => {
 | 
					      .map(item => {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
          version: item.correttoVersion,
 | 
					          version: convertVersionToSemver(item.correttoVersion),
 | 
				
			||||||
          url: item.downloadLink
 | 
					          url: item.downloadLink
 | 
				
			||||||
        } as JavaDownloadRelease;
 | 
					        } as JavaDownloadRelease;
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
				
			|||||||
@ -47,27 +47,28 @@ export class LocalDistribution extends JavaBase {
 | 
				
			|||||||
      const archivePath = path.join(extractedJavaPath, archiveName);
 | 
					      const archivePath = path.join(extractedJavaPath, archiveName);
 | 
				
			||||||
      const javaVersion = this.version;
 | 
					      const javaVersion = this.version;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let javaPath = await tc.cacheDir(
 | 
					      const javaPath = await tc.cacheDir(
 | 
				
			||||||
        archivePath,
 | 
					        archivePath,
 | 
				
			||||||
        this.toolcacheFolderName,
 | 
					        this.toolcacheFolderName,
 | 
				
			||||||
        this.getToolcacheVersionName(javaVersion),
 | 
					        this.getToolcacheVersionName(javaVersion),
 | 
				
			||||||
        this.architecture
 | 
					        this.architecture
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // for different Java distributions, postfix can exist or not so need to check both cases
 | 
					 | 
				
			||||||
      if (
 | 
					 | 
				
			||||||
        process.platform === 'darwin' &&
 | 
					 | 
				
			||||||
        fs.existsSync(path.join(javaPath, MACOS_JAVA_CONTENT_POSTFIX))
 | 
					 | 
				
			||||||
      ) {
 | 
					 | 
				
			||||||
        javaPath = path.join(javaPath, MACOS_JAVA_CONTENT_POSTFIX);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      foundJava = {
 | 
					      foundJava = {
 | 
				
			||||||
        version: javaVersion,
 | 
					        version: javaVersion,
 | 
				
			||||||
        path: javaPath
 | 
					        path: javaPath
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // JDK folder may contain postfix "Contents/Home" on macOS
 | 
				
			||||||
 | 
					    const macOSPostfixPath = path.join(
 | 
				
			||||||
 | 
					      foundJava.path,
 | 
				
			||||||
 | 
					      MACOS_JAVA_CONTENT_POSTFIX
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
 | 
				
			||||||
 | 
					      foundJava.path = macOSPostfixPath;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    core.info(`Setting Java ${foundJava.version} as default`);
 | 
					    core.info(`Setting Java ${foundJava.version} as default`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.setJavaDefault(foundJava.version, foundJava.path);
 | 
					    this.setJavaDefault(foundJava.version, foundJava.path);
 | 
				
			||||||
 | 
				
			|||||||
@ -10,6 +10,7 @@ import {IZuluVersions} from './models';
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
  extractJdkFile,
 | 
					  extractJdkFile,
 | 
				
			||||||
  getDownloadArchiveExtension,
 | 
					  getDownloadArchiveExtension,
 | 
				
			||||||
 | 
					  convertVersionToSemver,
 | 
				
			||||||
  isVersionSatisfies
 | 
					  isVersionSatisfies
 | 
				
			||||||
} from '../../util';
 | 
					} from '../../util';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
@ -29,9 +30,9 @@ export class ZuluDistribution extends JavaBase {
 | 
				
			|||||||
    const availableVersionsRaw = await this.getAvailableVersions();
 | 
					    const availableVersionsRaw = await this.getAvailableVersions();
 | 
				
			||||||
    const availableVersions = availableVersionsRaw.map(item => {
 | 
					    const availableVersions = availableVersionsRaw.map(item => {
 | 
				
			||||||
      return {
 | 
					      return {
 | 
				
			||||||
        version: this.convertVersionToSemver(item.jdk_version),
 | 
					        version: convertVersionToSemver(item.jdk_version),
 | 
				
			||||||
        url: item.url,
 | 
					        url: item.url,
 | 
				
			||||||
        zuluVersion: this.convertVersionToSemver(item.zulu_version)
 | 
					        zuluVersion: convertVersionToSemver(item.zulu_version)
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -172,15 +173,4 @@ export class ZuluDistribution extends JavaBase {
 | 
				
			|||||||
        return process.platform;
 | 
					        return process.platform;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Azul API returns jdk_version as array of digits like [11, 0, 2, 1]
 | 
					 | 
				
			||||||
  private convertVersionToSemver(version_array: number[]) {
 | 
					 | 
				
			||||||
    const mainVersion = version_array.slice(0, 3).join('.');
 | 
					 | 
				
			||||||
    if (version_array.length > 3) {
 | 
					 | 
				
			||||||
      // intentionally ignore more than 4 numbers because it is invalid semver
 | 
					 | 
				
			||||||
      return `${mainVersion}+${version_array[3]}`;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return mainVersion;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								src/util.ts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/util.ts
									
									
									
									
									
								
							@ -151,3 +151,13 @@ export function getVersionFromFileContent(
 | 
				
			|||||||
function avoidOldNotation(content: string): string {
 | 
					function avoidOldNotation(content: string): string {
 | 
				
			||||||
  return content.startsWith('1.') ? content.substring(2) : content;
 | 
					  return content.startsWith('1.') ? content.substring(2) : content;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function convertVersionToSemver(version: number[] | string) {
 | 
				
			||||||
 | 
					  // Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
 | 
				
			||||||
 | 
					  const versionArray = Array.isArray(version) ? version : version.split('.');
 | 
				
			||||||
 | 
					  const mainVersion = versionArray.slice(0, 3).join('.');
 | 
				
			||||||
 | 
					  if (versionArray.length > 3) {
 | 
				
			||||||
 | 
					    return `${mainVersion}+${versionArray.slice(3).join('.')}`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return mainVersion;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user