diff --git a/packages/gradle/src/executors/build/executor.ts b/packages/gradle/src/executors/build/executor.ts index e2834ccff..c32d9523b 100644 --- a/packages/gradle/src/executors/build/executor.ts +++ b/packages/gradle/src/executors/build/executor.ts @@ -18,10 +18,9 @@ export default async function runExecutor( let target = ''; - if ( - getPluginName(context) === '@jnxplus/nx-boot-gradle' || - options.framework === 'spring-boot' - ) { + if (options.command) { + target = options.command; + } else if (getPluginName(context) === '@jnxplus/nx-boot-gradle') { if (getProjectType(context) === 'library') { target = 'jar'; } else { @@ -34,21 +33,6 @@ export default async function runExecutor( } } - if ( - getPluginName(context) === '@jnxplus/nx-quarkus-gradle' || - options.framework === 'quarkus' - ) { - //use quarkusBuild (instead of build task) to not trigger test - target = 'quarkusBuild'; - } - - if ( - getPluginName(context) === '@jnxplus/nx-micronaut-gradle' || - options.framework === 'micronaut' - ) { - target = 'build -x test'; - } - //default build task if (!target) { target = 'build -x test'; diff --git a/packages/gradle/src/executors/build/schema.d.ts b/packages/gradle/src/executors/build/schema.d.ts index 8804397cc..2e147ee42 100644 --- a/packages/gradle/src/executors/build/schema.d.ts +++ b/packages/gradle/src/executors/build/schema.d.ts @@ -1,8 +1,11 @@ import { PackagingType } from '@jnxplus/common'; export interface BuildExecutorSchema { - packaging?: PackagingType; - framework?: 'spring-boot' | 'quarkus' | 'micronaut'; - args: string; projectPath?: string; + //TODO: make command mandatory + command?: string; + args?: string; + //TODO: remove packaging option and make command mandatory + //deprecated, use command to define your build command + packaging?: PackagingType; } diff --git a/packages/gradle/src/executors/build/schema.json b/packages/gradle/src/executors/build/schema.json index 37ca30391..6f98c18fb 100644 --- a/packages/gradle/src/executors/build/schema.json +++ b/packages/gradle/src/executors/build/schema.json @@ -6,12 +6,19 @@ "description": "", "type": "object", "properties": { + "projectPath": { + "type": "string" + }, + "command": { + "type": "string" + }, + "args": { + "type": "string" + }, "packaging": { "type": "string", + "description": "deprecated, use command to define your build command", "default": "jar" - }, - "projectPath": { - "type": "string" } }, "required": [] diff --git a/packages/gradle/src/executors/serve/executor.ts b/packages/gradle/src/executors/serve/executor.ts index 14270b44b..652d7544b 100644 --- a/packages/gradle/src/executors/serve/executor.ts +++ b/packages/gradle/src/executors/serve/executor.ts @@ -19,10 +19,7 @@ export default async function runExecutor( let command = `${getExecutable()} ${projectPath}:`; - if ( - getPluginName(context) === '@jnxplus/nx-boot-gradle' || - options.framework === 'spring-boot' - ) { + if (getPluginName(context) === '@jnxplus/nx-boot-gradle') { command += 'bootRun'; if (options.args) { @@ -30,20 +27,6 @@ export default async function runExecutor( } } - if ( - getPluginName(context) === '@jnxplus/nx-quarkus-gradle' || - options.framework === 'quarkus' - ) { - command += 'quarkusDev'; - } - - if ( - getPluginName(context) === '@jnxplus/nx-micronaut-gradle' || - options.framework === 'micronaut' - ) { - command += 'run'; - } - const result = runCommand(command); if (!result.success) { diff --git a/packages/gradle/src/executors/serve/schema.d.ts b/packages/gradle/src/executors/serve/schema.d.ts index f6d093c50..0e2e36f7c 100644 --- a/packages/gradle/src/executors/serve/schema.d.ts +++ b/packages/gradle/src/executors/serve/schema.d.ts @@ -1,5 +1,7 @@ export interface ServeExecutorSchema { - framework?: 'spring-boot' | 'quarkus' | 'micronaut'; - args: string; projectPath?: string; + //TODO: make command mandatory + command?: string; + //TODO: remove args and use only command + args?: string; } diff --git a/packages/gradle/src/executors/serve/schema.json b/packages/gradle/src/executors/serve/schema.json index 58c13da1b..8171d5c93 100644 --- a/packages/gradle/src/executors/serve/schema.json +++ b/packages/gradle/src/executors/serve/schema.json @@ -6,10 +6,13 @@ "description": "", "type": "object", "properties": { - "args": { + "projectPath": { "type": "string" }, - "projectPath": { + "command": { + "type": "string" + }, + "args": { "type": "string" } }, diff --git a/packages/gradle/src/generators/application/generator.ts b/packages/gradle/src/generators/application/generator.ts index 30e0b3204..cb952f537 100644 --- a/packages/gradle/src/generators/application/generator.ts +++ b/packages/gradle/src/generators/application/generator.ts @@ -390,10 +390,18 @@ export default async function ( targets: { build: { executor: `${plugin}:build`, + options: { + command: 'build -x test', + }, outputs: [`${normalizedOptions.projectRoot}/build`], }, 'build-image': {}, - serve: {}, + serve: { + executor: `${plugin}:serve`, + options: { + command: 'run', + }, + }, lint: { executor: `${plugin}:lint`, options: { @@ -416,43 +424,36 @@ export default async function ( ) { targets['build'].options = { ...targets['build'].options, - packaging: `${normalizedOptions.packaging}`, + command: normalizedOptions.packaging === 'war' ? 'bootWar' : 'bootJar', }; - } - if (options.framework === 'none') { - targets['serve'] = { - executor: `${plugin}:run-task`, - options: { - task: 'run', - }, - }; - } - - if (options.framework !== 'none') { - targets['build-image'] = { - executor: `${plugin}:build-image`, - }; - - targets['serve'] = { - executor: `${plugin}:serve`, + targets['serve'].options = { + ...targets['serve'].options, + command: 'bootRun', }; } - if (options.framework && options.framework !== 'none') { + if ( + plugin === '@jnxplus/nx-quarkus-gradle' || + options.framework === 'quarkus' + ) { targets['build'].options = { ...targets['build'].options, - framework: options.framework, - }; - - targets['build-image'].options = { - ...targets['build-image'].options, - framework: options.framework, + command: 'quarkusBuild', }; targets['serve'].options = { ...targets['serve'].options, - framework: options.framework, + command: 'quarkusDev', + }; + } + + if (options.framework && options.framework !== 'none') { + targets['build-image'] = { + executor: `${plugin}:build-image`, + options: { + framework: options.framework, + }, }; } diff --git a/packages/gradle/src/generators/library/generator.ts b/packages/gradle/src/generators/library/generator.ts index b5f36d2cd..22ec09164 100644 --- a/packages/gradle/src/generators/library/generator.ts +++ b/packages/gradle/src/generators/library/generator.ts @@ -322,6 +322,9 @@ export default async function ( targets: { build: { executor: `${plugin}:build`, + options: { + command: 'build -x test', + }, outputs: [`${normalizedOptions.projectRoot}/build`], }, lint: { @@ -339,11 +342,13 @@ export default async function ( const targets = projectConfiguration.targets ?? {}; - //this is important because in case of spring boot we use jar task to build libraries - if (options.framework && options.framework !== 'none') { + if ( + plugin === '@jnxplus/nx-boot-gradle' || + options.framework === 'spring-boot' + ) { targets['build'].options = { ...targets['build'].options, - framework: options.framework, + command: 'jar', }; }