From f3726bea4618b328f3644dadf8898ea9ec8a7c95 Mon Sep 17 00:00:00 2001 From: lgmyrek_cp Date: Fri, 1 Mar 2024 20:07:39 +0100 Subject: [PATCH 1/2] Add support for setting Coursier's --extra-jars option when launching Scala Steward --- action.yml | 5 +++++ src/action/main.ts | 2 +- src/modules/coursier.ts | 3 +++ src/modules/input.test.ts | 2 ++ src/modules/input.ts | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b1562110..f8619771 100644 --- a/action.yml +++ b/action.yml @@ -51,6 +51,11 @@ inputs: Url to download the coursier linux CLI from. default: https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz required: false + extra-jars: + description: | + Extra JARs to be added to the classpath of the + launched application. Directories accepted too. + required: false github-api-url: description: | The URL of the GitHub API, only use this input if diff --git a/src/action/main.ts b/src/action/main.ts index 46856d0e..04b5e308 100644 --- a/src/action/main.ts +++ b/src/action/main.ts @@ -74,7 +74,7 @@ async function run(): Promise { '--do-not-fork', '--disable-sandbox', inputs.steward.extraArgs?.value.split(' ') ?? [], - ]) + ], inputs.steward.extraJars) if (files.existsSync(workspace.runSummary_md)) { logger.info(`✓ Run Summary file: ${workspace.runSummary_md}`) diff --git a/src/modules/coursier.ts b/src/modules/coursier.ts index 05b8f4d6..d6f433a4 100644 --- a/src/modules/coursier.ts +++ b/src/modules/coursier.ts @@ -65,10 +65,12 @@ export async function install(): Promise { * * @param app - The application to launch * @param arguments_ - The args to pass to the application launcher. + * @param extraJars - Extra JARs to be added to the classpath of the launched application. Directories accepted too. */ export async function launch( app: string, arguments_: Array = [], + extraJars: NonEmptyString | undefined, ): Promise { core.startGroup(`Launching ${app}`) @@ -78,6 +80,7 @@ export async function launch( '-r', 'sonatype:snapshots', app, + ...(extraJars ? ['--extra-jars', extraJars.value] : []), '--', ...arguments_.flatMap((argument: string | string[]) => (typeof argument === 'string' ? [argument] : argument)), ] diff --git a/src/modules/input.test.ts b/src/modules/input.test.ts index 67eae484..8735da1a 100644 --- a/src/modules/input.test.ts +++ b/src/modules/input.test.ts @@ -23,6 +23,7 @@ test('`Input.all` → returns all inputs', t => { .with('scalafix-migrations', () => '.github/scalafix-migrations.conf') .with('other-args', () => '--help') .with('signing-key', () => '42') + .with('extra-jars', () => 'path/to/my/jars') .otherwise(() => '') const booleanInputs = (name: string) => match(name) @@ -56,6 +57,7 @@ test('`Input.all` → returns all inputs', t => { timeout: nonEmpty('60s'), ignoreOptsFiles: true, extraArgs: nonEmpty('--help'), + extraJars: nonEmpty('path/to/my/jars'), }, migrations: { scalafix: nonEmpty('.github/scalafix-migrations.conf'), diff --git a/src/modules/input.ts b/src/modules/input.ts index 8828fc16..f67d06f5 100644 --- a/src/modules/input.ts +++ b/src/modules/input.ts @@ -47,6 +47,7 @@ export class Input { timeout: nonEmpty(this.inputs.getInput('timeout')), ignoreOptsFiles: this.inputs.getBooleanInput('ignore-opts-files'), extraArgs: nonEmpty(this.inputs.getInput('other-args')), + extraJars: nonEmpty(this.inputs.getInput('extra-jars')), }, migrations: { scalafix: nonEmpty(this.inputs.getInput('scalafix-migrations')), From e0b735b00b0405ad391bb33f7fd9c65738e7b512 Mon Sep 17 00:00:00 2001 From: lgmyrek_cp Date: Mon, 4 Mar 2024 20:07:42 +0100 Subject: [PATCH 2/2] fixed code-style checks issues --- src/modules/coursier.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/coursier.ts b/src/modules/coursier.ts index d6f433a4..38ab1e38 100644 --- a/src/modules/coursier.ts +++ b/src/modules/coursier.ts @@ -70,7 +70,7 @@ export async function install(): Promise { export async function launch( app: string, arguments_: Array = [], - extraJars: NonEmptyString | undefined, + extraJars: NonEmptyString | undefined = undefined, ): Promise { core.startGroup(`Launching ${app}`) @@ -80,7 +80,7 @@ export async function launch( '-r', 'sonatype:snapshots', app, - ...(extraJars ? ['--extra-jars', extraJars.value] : []), + ...(extraJars ? ['--extra-jars', extraJars.value] : []), '--', ...arguments_.flatMap((argument: string | string[]) => (typeof argument === 'string' ? [argument] : argument)), ]