mirror of
				https://github.com/actions/setup-java.git
				synced 2025-10-31 22:40:54 +00:00 
			
		
		
		
	actions/setup-java@v2 - Support different distributions (#132)
* Implement support for custom vendors in setup-java * minor improvements * minor refactoring * Add unit tests and e2e tests * Update documentation for setup-java@v2 release * minor improvements * regenerate dist * fix comments * resolve comments * resolve comments * fix tests * Update README.md Co-authored-by: George Adams <george.adams@microsoft.com> * Apply suggestions from code review Co-authored-by: Konrad Pabjan <konradpabjan@github.com> * fix minor nitpicks * handle 4th digit * pull latest main * Update README.md * rename adoptium to adopt * rename adoptium to adopt * rename adoptium to adopt * Update README.md * make java-version and distribution required for action * update readme * fix tests * fix e2e tests Co-authored-by: George Adams <george.adams@microsoft.com> Co-authored-by: Konrad Pabjan <konradpabjan@github.com>
This commit is contained in:
		
					parent
					
						
							
								e73e96a93b
							
						
					
				
			
			
				commit
				
					
						7c88894700
					
				
			
		
					 44 changed files with 40141 additions and 22003 deletions
				
			
		|  | @ -1,60 +1,43 @@ | |||
| import * as core from '@actions/core'; | ||||
| import * as installer from './installer'; | ||||
| import * as auth from './auth'; | ||||
| import * as gpg from './gpg'; | ||||
| 
 | ||||
| import * as constants from './constants'; | ||||
| import * as path from 'path'; | ||||
| import { getJavaDistribution } from './distributions/distribution-factory'; | ||||
| import { JavaInstallerOptions } from './distributions/base-models'; | ||||
| 
 | ||||
| async function run() { | ||||
|   try { | ||||
|     let version = core.getInput(constants.INPUT_VERSION); | ||||
|     if (!version) { | ||||
|       version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true}); | ||||
|     const version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true }); | ||||
|     const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); | ||||
|     const architecture = core.getInput(constants.INPUT_ARCHITECTURE); | ||||
|     const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); | ||||
|     const jdkFile = core.getInput(constants.INPUT_JDK_FILE); | ||||
| 
 | ||||
|     const installerOptions: JavaInstallerOptions = { | ||||
|       architecture, | ||||
|       packageType, | ||||
|       version | ||||
|     }; | ||||
| 
 | ||||
|     const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile); | ||||
|     if (!distribution) { | ||||
|       throw new Error(`No supported distribution was found for input ${distributionName}`); | ||||
|     } | ||||
| 
 | ||||
|     const arch = core.getInput(constants.INPUT_ARCHITECTURE, {required: true}); | ||||
|     if (!['x86', 'x64'].includes(arch)) { | ||||
|       throw new Error(`architecture "${arch}" is not in [x86 | x64]`); | ||||
|     } | ||||
|     const result = await distribution.setupJava(); | ||||
| 
 | ||||
|     const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, { | ||||
|       required: true | ||||
|     }); | ||||
|     const jdkFile = core.getInput(constants.INPUT_JDK_FILE, {required: false}); | ||||
| 
 | ||||
|     await installer.getJava(version, arch, jdkFile, javaPackage); | ||||
|     core.info(''); | ||||
|     core.info('Java configuration:'); | ||||
|     core.info(`  Distribution: ${distributionName}`); | ||||
|     core.info(`  Version: ${result.version}`); | ||||
|     core.info(`  Path: ${result.path}`); | ||||
|     core.info(''); | ||||
| 
 | ||||
|     const matchersPath = path.join(__dirname, '..', '..', '.github'); | ||||
|     core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); | ||||
| 
 | ||||
|     const id = core.getInput(constants.INPUT_SERVER_ID, {required: false}); | ||||
|     const username = core.getInput(constants.INPUT_SERVER_USERNAME, { | ||||
|       required: false | ||||
|     }); | ||||
|     const password = core.getInput(constants.INPUT_SERVER_PASSWORD, { | ||||
|       required: false | ||||
|     }); | ||||
|     const gpgPrivateKey = | ||||
|       core.getInput(constants.INPUT_GPG_PRIVATE_KEY, {required: false}) || | ||||
|       constants.INPUT_DEFAULT_GPG_PRIVATE_KEY; | ||||
|     const gpgPassphrase = | ||||
|       core.getInput(constants.INPUT_GPG_PASSPHRASE, {required: false}) || | ||||
|       (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined); | ||||
| 
 | ||||
|     if (gpgPrivateKey) { | ||||
|       core.setSecret(gpgPrivateKey); | ||||
|     } | ||||
| 
 | ||||
|     await auth.configAuthentication(id, username, password, gpgPassphrase); | ||||
| 
 | ||||
|     if (gpgPrivateKey) { | ||||
|       core.info('importing private key'); | ||||
|       const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || ''; | ||||
|       core.saveState( | ||||
|         constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, | ||||
|         keyFingerprint | ||||
|       ); | ||||
|     } | ||||
|     await auth.configureAuthentication(); | ||||
|   } catch (error) { | ||||
|     core.setFailed(error.message); | ||||
|   } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue