Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --jvm-index #465

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -18,6 +18,11 @@ Inspired by [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) and
- `jvm` (optional): JVM to install
- one of the options from `cs java --available`.
- if left empty either the existing JVM will be used or Coursier will install its default JVM.

- `jvm-index` (optional): The JVM index source
- arbitrary URL containing the JVM index source like in `cs java --available --jvm-index https://url/of/your/index.json`.
- if left empty the coursier index will be used as default JVM index source

- `apps` (optional): Scala apps to install (`sbtn` by default)
- space separated list of app names (from the [main channel](https://github.com/coursier/apps))

Expand All @@ -29,6 +34,7 @@ Inspired by [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) and
- uses: coursier/setup-action@v1
with:
jvm: adopt:11
jvm-index: https://url/of/your/index.json
apps: sbtn bloop ammonite
```

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Expand Up @@ -9,6 +9,10 @@ inputs:
description: 'JVM to install (leave empty to use default)'
required: false
default: ''
jvm-index:
description: 'Arbitrary URL containing the JVM index source (leave empty to use default)'
required: false
default: ''
apps:
description: 'Applications to install'
required: false
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Expand Up @@ -107,12 +107,14 @@ async function run(): Promise<void> {

await core.group('Install JVM', async () => {
const jvmInput = core.getInput('jvm')
const jvmIndexInput = core.getInput('jvm-index')
const jvmArg = jvmInput ? ['--jvm', jvmInput] : []
const jvmIndexArg = jvmIndexInput ? ['--jvm-index', jvmIndexInput] : []
if (!jvmInput && process.env.JAVA_HOME) {
core.info(`skipping, JVM is already installed in ${process.env.JAVA_HOME}`)
} else {
await cs('java', ...jvmArg, '-version')
const csJavaHome = await cs('java-home', ...jvmArg)
await cs('java', ...jvmArg, ...jvmIndexArg, '-version')
const csJavaHome = await cs('java-home', ...jvmArg, ...jvmIndexArg)
core.exportVariable('JAVA_HOME', csJavaHome)
core.addPath(path.join(csJavaHome, 'bin'))
}
Expand Down