From 3081ff5a3eeb09867f395b5a8ab399df6d0a4d7b Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Wed, 1 May 2024 12:37:50 +0000 Subject: [PATCH] fix(common-jvm): fix command to run `Gradle` tasks --- .../src/lib/builders/gradle-builder.class.ts | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/common-jvm/src/lib/builders/gradle-builder.class.ts b/packages/common-jvm/src/lib/builders/gradle-builder.class.ts index c2a13742..237ee100 100644 --- a/packages/common-jvm/src/lib/builders/gradle-builder.class.ts +++ b/packages/common-jvm/src/lib/builders/gradle-builder.class.ts @@ -9,7 +9,7 @@ import { hasGradleModule, hasGradleWrapper, hasGradleProject } from '../utils'; import { basename, resolve } from 'path'; export class GradleBuilder implements BuilderCore { - constructor(private commandAliases: BuilderCommandAliasMapper) { } + constructor(private commandAliases: BuilderCommandAliasMapper) {} getBuildSystemType() { return BuildSystem.GRADLE; @@ -19,16 +19,29 @@ export class GradleBuilder implements BuilderCore { return ignoreWrapper ? GRADLE_EXECUTABLE : GRADLE_WRAPPER_EXECUTABLE; } - getCommand(alias: BuilderCommandAliasType, options: { cwd: string, ignoreWrapper?: boolean, runFromParentModule?: boolean }) { + getCommand( + alias: BuilderCommandAliasType, + options: { + cwd: string; + ignoreWrapper?: boolean; + runFromParentModule?: boolean; + } + ) { let additionalArgs = ''; let cwd = options.cwd; - if (!options.ignoreWrapper && !hasGradleWrapper(options.cwd) && !options.runFromParentModule) { - throw new Error(`⚠️ You chose not to use the Gradle wrapper from the parent module, but no wrapper was found in current child module`); + if ( + !options.ignoreWrapper && + !hasGradleWrapper(options.cwd) && + !options.runFromParentModule + ) { + throw new Error( + `⚠️ You chose not to use the Gradle wrapper from the parent module, but no wrapper was found in current child module` + ); } - + + let pathToModule: string[] = []; if (options.runFromParentModule) { - let pathToModule:string[] = []; const childModuleName = basename(cwd); do { const module = basename(cwd); @@ -36,9 +49,9 @@ export class GradleBuilder implements BuilderCore { pathToModule = [module, ...pathToModule]; } while (!hasGradleModule(cwd, childModuleName)); - additionalArgs = `-p ${pathToModule.join('/')} `; + additionalArgs = `${pathToModule.join(':')}`; } - return { cwd, command: `${additionalArgs}${this.commandAliases[alias]}` }; + return { cwd, command: `${additionalArgs}${pathToModule.length ? ':' : ''}${this.commandAliases[alias]}` }; } }