From 6ef262c93153b84dadfe67345e63c622a10a21a9 Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Thu, 9 May 2024 06:36:58 +0000 Subject: [PATCH] feat(nx-quarkus): add option to choose which version of Java to use --- .../src/generators/preset/schema.json | 24 +++++++++++++++++++ .../src/generators/project/generator.spec.ts | 3 ++- .../src/generators/project/schema.d.ts | 1 + .../src/generators/project/schema.json | 24 +++++++++++++++++++ .../nx-quarkus/src/utils/quarkus-utils.ts | 1 + 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/packages/nx-quarkus/src/generators/preset/schema.json b/packages/nx-quarkus/src/generators/preset/schema.json index cace5825..229e2ccd 100644 --- a/packages/nx-quarkus/src/generators/preset/schema.json +++ b/packages/nx-quarkus/src/generators/preset/schema.json @@ -64,6 +64,30 @@ }, "x-priority": "important" }, + "javaVersion": { + "description": "Java version.", + "type": "string", + "default": "17", + "enum": [ + "17", + "21" + ], + "x-prompt": { + "message": "Which version of Java would you like to use?", + "type": "list", + "items": [ + { + "value": "21", + "label": "21" + }, + { + "value": "17", + "label": "17" + } + ] + }, + "x-priority": "important" + }, "groupId": { "description": "Group Id of the project.", "type": "string", diff --git a/packages/nx-quarkus/src/generators/project/generator.spec.ts b/packages/nx-quarkus/src/generators/project/generator.spec.ts index e5f37907..c2c792bc 100644 --- a/packages/nx-quarkus/src/generators/project/generator.spec.ts +++ b/packages/nx-quarkus/src/generators/project/generator.spec.ts @@ -98,6 +98,7 @@ describe('project generator', () => { groupId: 'com.tinesoft', artifactId: 'demo', buildSystem: 'MAVEN', + javaVersion: '17', quarkusInitializerUrl: DEFAULT_QUARKUS_INITIALIZR_URL, }; @@ -133,7 +134,7 @@ describe('project generator', () => { wrapperName, }) => { const rootDir = '.'; - const downloadUrl = `${options.quarkusInitializerUrl}/d?b=${buildSystem}&g=${options.groupId}&a=${options.artifactId}`; + const downloadUrl = `${options.quarkusInitializerUrl}/d?b=${buildSystem}&j=${options.javaVersion}&g=${options.groupId}&a=${options.artifactId}`; const zipFiles = [ { diff --git a/packages/nx-quarkus/src/generators/project/schema.d.ts b/packages/nx-quarkus/src/generators/project/schema.d.ts index 7bba3cdf..d0453c78 100644 --- a/packages/nx-quarkus/src/generators/project/schema.d.ts +++ b/packages/nx-quarkus/src/generators/project/schema.d.ts @@ -11,6 +11,7 @@ export interface ProjectGeneratorOptions { proxyUrl?: string; buildSystem: 'MAVEN' | 'GRADLE' | 'GRADLE_KOTLIN_DSL'; + javaVersion?: string; groupId?: string; artifactId?: string; skipCodeSamples?: boolean; diff --git a/packages/nx-quarkus/src/generators/project/schema.json b/packages/nx-quarkus/src/generators/project/schema.json index f809ebf3..c190931a 100644 --- a/packages/nx-quarkus/src/generators/project/schema.json +++ b/packages/nx-quarkus/src/generators/project/schema.json @@ -68,6 +68,30 @@ }, "x-priority": "important" }, + "javaVersion": { + "description": "Java version.", + "type": "string", + "default": "17", + "enum": [ + "17", + "21" + ], + "x-prompt": { + "message": "Which version of Java would you like to use?", + "type": "list", + "items": [ + { + "value": "21", + "label": "21" + }, + { + "value": "17", + "label": "17" + } + ] + }, + "x-priority": "important" + }, "groupId": { "description": "Group Id of the project.", "type": "string", diff --git a/packages/nx-quarkus/src/utils/quarkus-utils.ts b/packages/nx-quarkus/src/utils/quarkus-utils.ts index 14aab433..2f9ee79b 100644 --- a/packages/nx-quarkus/src/utils/quarkus-utils.ts +++ b/packages/nx-quarkus/src/utils/quarkus-utils.ts @@ -48,6 +48,7 @@ export function runQuarkusPluginCommand( export function buildQuarkusDownloadUrl(options: NormalizedSchema) { const params = [ { key: 'b', value: options.buildSystem }, + { key: 'j', value: options.javaVersion }, { key: 'g', value: options.groupId }, { key: 'a', value: options.artifactId }, { key: 'v', value: options.version },