Skip to content

Commit

Permalink
Add support for --jvm-index (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurz committed Sep 25, 2023
1 parent 6a582d7 commit 98c9273
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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

0 comments on commit 98c9273

Please sign in to comment.