nxrocks icon indicating copy to clipboard operation
nxrocks copied to clipboard

[Bug] Unable to create new Spring Boot application with the latest version of NX

Open Divaaaaaan opened this issue 1 year ago • 5 comments

Plugin Name

@nxrocks/nx-spring-boot

Nx Report


 NX   Report complete - copy this into the issue template

Node           : 20.18.0
OS             : linux-x64
Native Target  : x86_64-linux
bun            : 1.1.30

nx             : 20.0.0
@nx/js         : 20.0.0
@nx/eslint     : 20.0.0
@nx/workspace  : 20.0.0
@nx/angular    : 20.0.0
@nx/devkit     : 20.0.0
@nx/vite       : 20.0.0
@nx/web        : 20.0.0
@nx/webpack    : 20.0.0
typescript     : 5.6.3
---------------------------------------
Community plugins:
@analogjs/content             : 1.8.2
@analogjs/platform            : 1.8.2
@analogjs/router              : 1.8.2
@analogjs/vite-plugin-angular : 1.8.2
@nxrocks/nx-spring-boot       : 10.2.6

### Expected Behaviour

Create a project using `nx g @nxrocks/nx-spring-boot:project`.

### Actual Behaviour

```~/Workspace/Work/Bedrock git:[main] bunx nx g @nxrocks/nx-spring-boot:project test --verbose

 NX  Generating @nxrocks/nx-spring-boot:project

✔ What kind of project are you generating? · application
✔ Which build system would you like to use? · maven-project
✔ Which packaging would you like to use? · jar
✔ Which version of Java would you like to use? · 22
✔ Which language would you like to use? · java
✔ What groupId would you like to use? · com.test
✔ What artifactId would you like to use? · test
✔ What package name would you like to use? · com.test.api

 NX   Cannot read properties of undefined (reading 'replace')

TypeError: Cannot read properties of undefined (reading 'replace')
    at removeWindowsDriveLetter (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/utils/path.js:9:27)
    at normalizePath (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/utils/path.js:16:12)
    at determineProjectNameAndRootOptions (/home/user/Workspace/Work/Bedrock/node_modules/@nx/devkit/src/generators/project-name-and-root-utils.js:10:58)
    at normalizeOptions (/home/user/Workspace/Work/Bedrock/node_modules/@nxrocks/nx-spring-boot/src/generators/project/lib/normalize-options.js:6:144)
    at projectGenerator (/home/user/Workspace/Work/Bedrock/node_modules/@nxrocks/nx-spring-boot/src/generators/project/generator.js:9:64)
    at /home/user/Workspace/Work/Bedrock/node_modules/nx/src/command-line/generate/generate.js:238:32
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handleErrors (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/utils/handle-errors.js:9:24)
    at async Object.handler (/home/user/Workspace/Work/Bedrock/node_modules/nx/src/command-line/generate/command-object.js:14:22)

### Steps to reproduce the behaviour

1. Create new nx workspace with "none" preset
2. Install @nxrocks/nx-spring-boot
3. Try and create a spring boot application

Divaaaaaan avatar Oct 14 '24 10:10 Divaaaaaan

It seems like the options.directory value is null when logging out the options in normalize-options.js

Divaaaaaan avatar Oct 14 '24 11:10 Divaaaaaan

Hi @Divaaaaaan

Thanks for reporting this, I'll have a look and provide an update soonish.

Stay tuned!

tinesoft avatar Oct 14 '24 11:10 tinesoft

Hi @tinesoft

Cool no worries, did some investigating quick and it seems like the structure might have changed as the options for the generator doesn't seem to be passed through anymore. In the interim, I just updated that file to use options.name as the directory as well which is working but hope this helps make the checking on your side quicker and easier.

Divaaaaaan avatar Oct 14 '24 11:10 Divaaaaaan

@tinesoft Just an update, seems like things are not playing well together when I edited the file :sweat_smile: so will wait for the update rather before continuing.

Divaaaaaan avatar Oct 14 '24 19:10 Divaaaaaan

Having a look at the Nx plugin registry, it supports the Nx version between 16 and 18. When will the plugin be updated accordingly? Let me know if I can help upgrading.

WodenWang820118 avatar Oct 14 '24 22:10 WodenWang820118

Hi @Divaaaaaan.

"In Nx 20, generating projects will no longer derive the name and root"

So the correct way to create projects now is: nx g @nxrocks/nx-spring-boot:project testapp --directory apps/testapp This same change affects both Spring Boot and Flutter projects in Nx 20. CleanShot 2024-10-28 at 4  18 22@2x

lordvins226 avatar Oct 28 '24 16:10 lordvins226

@lordvins226 Ah great, didn't see that in Nx 20. Thank you very much will have a look :ok_hand:

Divaaaaaan avatar Oct 29 '24 06:10 Divaaaaaan

Hi @Divaaaaaan.

"In Nx 20, generating projects will no longer derive the name and root"

So the correct way to create projects now is: nx g @nxrocks/nx-spring-boot:project testapp --directory apps/testapp This same change affects both Spring Boot and Flutter projects in Nx 20. CleanShot 2024-10-28 at 4  18 22@2x

I seem to have this exact same problem here, I do not seem to understand how to do the fix you suggested on my end.

image

crafael23 avatar Nov 12 '24 04:11 crafael23

Hi all

@crafael23 I'm actively updating all the create-nx-* packages for official support for Nx 20. It should be released very soon.

I'll post back here when available.

tinesoft avatar Nov 12 '24 15:11 tinesoft

@lordvins226 thank you very much, it works for me. you save my time.

mostafamt avatar Dec 02 '24 16:12 mostafamt

Screenshot 2024-12-20 123551

i got the some problem and try to fix but it not work.

how to fix this problem ?

Hychin123 avatar Dec 20 '24 05:12 Hychin123

lordvins226, hello! Thank you very much for providing a workaround! :heartbeat:

Ossowitz avatar Dec 28 '24 18:12 Ossowitz

Screenshot 2024-12-20 123551

i got the some problem and try to fix but it not work.

how to fix this problem ?

@Hychin123 correct command: npx nx g @nxrocks/nx-spring-boot:project ecom-backend --directory apps/ecom-backend

lordvins226 avatar Dec 28 '24 18:12 lordvins226

Sorry for the long overdue....

Supports for Nx v20+ has officially landed with latest versions of the plugin.

tinesoft avatar Mar 23 '25 13:03 tinesoft