mirror of
https://gitea.com/actions/setup-java.git
synced 2025-11-08 02:46:26 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bb50d97d6 | ||
|
|
fe06bcdc44 | ||
|
|
d34a7e45c8 |
@@ -8,21 +8,21 @@
|
||||
|
||||
### NCC
|
||||
|
||||
In order to avoid uploading `node_modules` to the repository, we use [zeit/ncc](https://github.com/zeit/ncc) to create a single `index.js` file that gets saved in `dist/`.
|
||||
In order to avoid uploading `node_modules` to the repository, we use [zeit/ncc](https://github.com/zeit/ncc) to create multiple `index.js` files that gets saved under `dist/`.
|
||||
There are two main files that get created
|
||||
- `dist/setup/index.js`
|
||||
- Core `setup-java` logic that downloads and installs an appropriate version of Java
|
||||
- Handling creating a `settings.xml` file to make it easier to publish packages
|
||||
- `dist/cleanup/index/js`
|
||||
- Extra cleanup script that is used to remove GPG keys (needed for certain self-hosted runner scenarios)
|
||||
|
||||
If you're developing locally you can run
|
||||
```
|
||||
npm install
|
||||
tsc
|
||||
ncc build
|
||||
```
|
||||
You can also do
|
||||
```
|
||||
npm run-script build # runs tsc
|
||||
npm run-script format # runs prettier --write
|
||||
npm run-script format-check # runs prettier --check
|
||||
npm run-script test # runs jest
|
||||
npm run-script release # runs ncc build
|
||||
If you're developing locally, after doing `npm install`, you can use the following commands
|
||||
```yaml
|
||||
npm run build # runs tsc along with ncc
|
||||
npm run format # runs prettier --write
|
||||
npm run format-check # runs prettier --check
|
||||
npm run test # runs jest
|
||||
npm run release # add all the necessary ncc files under dist/* to the git staging area
|
||||
```
|
||||
|
||||
Any files generated using `tsc` will be added to `lib/*`, however those files also are not uploaded to the repository and are excluded using `.gitignore`.
|
||||
5054
dist/index.js
generated
vendored
5054
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
15
dist/setup/index.js
vendored
15
dist/setup/index.js
vendored
@@ -28685,6 +28685,9 @@ function run() {
|
||||
version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
|
||||
}
|
||||
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 javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
|
||||
required: true
|
||||
});
|
||||
@@ -33423,7 +33426,7 @@ function getJava(version, arch, jdkFile, javaPackage) {
|
||||
}
|
||||
const contents = yield response.readBody();
|
||||
const refs = contents.match(/<a href.*\">/gi) || [];
|
||||
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
|
||||
const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
|
||||
jdkFile = yield tc.downloadTool(downloadInfo.url);
|
||||
version = downloadInfo.version;
|
||||
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||
@@ -33539,20 +33542,22 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function getDownloadInfo(refs, version, javaPackage) {
|
||||
function getDownloadInfo(refs, version, arch, javaPackage) {
|
||||
version = normalizeVersion(version);
|
||||
const archExtension = arch === 'x86' ? 'i686' : 'x64';
|
||||
let extension = '';
|
||||
if (IS_WINDOWS) {
|
||||
extension = `-win_x64.zip`;
|
||||
extension = `-win_${archExtension}.zip`;
|
||||
}
|
||||
else {
|
||||
if (process.platform === 'darwin') {
|
||||
extension = `-macosx_x64.tar.gz`;
|
||||
extension = `-macosx_${archExtension}.tar.gz`;
|
||||
}
|
||||
else {
|
||||
extension = `-linux_x64.tar.gz`;
|
||||
extension = `-linux_${archExtension}.tar.gz`;
|
||||
}
|
||||
}
|
||||
core.debug(`Searching for files with extension: ${extension}`);
|
||||
let pkgRegexp = new RegExp('');
|
||||
let pkgTypeLength = 0;
|
||||
if (javaPackage === 'jdk') {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "setup java action",
|
||||
"main": "dist/index.js",
|
||||
"main": "dist/setup/index.js",
|
||||
"scripts": {
|
||||
"build": "ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts",
|
||||
"format": "prettier --write **/*.ts",
|
||||
|
||||
@@ -45,7 +45,7 @@ export async function getJava(
|
||||
|
||||
const contents = await response.readBody();
|
||||
const refs = contents.match(/<a href.*\">/gi) || [];
|
||||
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
|
||||
const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
|
||||
jdkFile = await tc.downloadTool(downloadInfo.url);
|
||||
version = downloadInfo.version;
|
||||
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||
@@ -181,20 +181,26 @@ async function unzipJavaDownload(
|
||||
function getDownloadInfo(
|
||||
refs: string[],
|
||||
version: string,
|
||||
arch: string,
|
||||
javaPackage: string
|
||||
): {version: string; url: string} {
|
||||
version = normalizeVersion(version);
|
||||
|
||||
const archExtension = arch === 'x86' ? 'i686' : 'x64';
|
||||
|
||||
let extension = '';
|
||||
if (IS_WINDOWS) {
|
||||
extension = `-win_x64.zip`;
|
||||
extension = `-win_${archExtension}.zip`;
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
extension = `-macosx_x64.tar.gz`;
|
||||
extension = `-macosx_${archExtension}.tar.gz`;
|
||||
} else {
|
||||
extension = `-linux_x64.tar.gz`;
|
||||
extension = `-linux_${archExtension}.tar.gz`;
|
||||
}
|
||||
}
|
||||
|
||||
core.debug(`Searching for files with extension: ${extension}`);
|
||||
|
||||
let pkgRegexp = new RegExp('');
|
||||
let pkgTypeLength = 0;
|
||||
if (javaPackage === 'jdk') {
|
||||
|
||||
@@ -11,7 +11,12 @@ async function run() {
|
||||
if (!version) {
|
||||
version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true});
|
||||
}
|
||||
|
||||
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 javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
|
||||
required: true
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user