Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JHipster generator can't regenerate a jdl change (using issue for one or more Application JDLs) #27944

Closed
3 tasks done
jperezdelafuente opened this issue Nov 20, 2024 · 8 comments

Comments

@jperezdelafuente
Copy link
Contributor

jperezdelafuente commented Nov 20, 2024

Overview of the issue

I can't regenerate the application with changes in jdl
I indicate the 3 steps to reproduce:

  1. I create an application with "jhipster jdl foo.jh" (foo.jh like a JDL definitions section)
  2. I add an attribute called foo2 to the entity foo (in the file a second JDL definitions section with second foo2 attribute)
 /* Foo 2 */
foo2 String required maxlength(30)
  1. I try to regenerate the application with "jhipster jdl foo.jh"
JHipster JDL
JDL definitions
 application {
  config {
    applicationType monolith,
    baseName foo,
    packageName com.foo,
    jhiPrefix gsr,
    authenticationType session,
    databaseType sql,
    devDatabaseType h2Disk,
    prodDatabaseType postgresql,
    enableHibernateCache true,
    cacheProvider ehcache,
    buildTool maven,
    testFrameworks [cypress, gatling, cucumber],
    clientFramework angular,
    enableTranslation true,
    nativeLanguage es,
    languages [es, en]
    incrementalChangelog true
  }
  entities *
}

/** Entity Foo */

entity Foo(foo) {

/* Foo */
foo String required maxlength(20)

}

dto * with mapstruct

service all with serviceImpl

paginate all with pagination

JDL definitions (incremental with second foo2 attribute)
 application {
  config {
    applicationType monolith,
    baseName foo,
    packageName com.foo,
    jhiPrefix gsr,
    authenticationType session,
    databaseType sql,
    devDatabaseType h2Disk,
    prodDatabaseType postgresql,
    enableHibernateCache true,
    cacheProvider ehcache,
    buildTool maven,
    testFrameworks [cypress, gatling, cucumber],
    clientFramework angular,
    enableTranslation true,
    nativeLanguage es,
    languages [es, en]
    incrementalChangelog true
  }
  entities *
}

/** Entity Foo */

entity Foo(foo) {

/* Foo */
foo String required maxlength(20)

/* Foo2 */
foo2 String maxlength(20)

}

dto * with mapstruct

service all with serviceImpl

paginate all with pagination

  • JDL is mandatory for bug reports. This will allow us to use automated tests and genarate the broken sample using jhipster from-issue command.
Motivation for or Use Case

Perform regenerations in the application with changes in the jdl

Reproduce the error

With Node v22.11.0 It finishes without errors and without trying to regenerate the rest of the files

(node:29595) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
     info KeyStore '/home/foo22/src/main/resources/config/tls/keystore.p12' already exists. Leaving unchanged.
[@faker-js/faker]: faker.internet.userName() is deprecated since v9.1.0 and will be removed in v10.0.0. Please use faker.internet.username() instead.
✔ applying multi-step templates
     info Using existing git repository.
identical .prettierrc
identical .prettierignore
✔ prettier configuration files committed to disk
✔ loading translations
✔ updating package.json dependencies versions
✔ prettifying sonar-project.properties
✔ adding package-info.java files
✔ sorting pom.xml file
✔ translating angular application
identical sonar-project.properties
identical .husky/pre-commit
identical src/main/resources/banner.txt
identical .devcontainer/Dockerfile
identical pom.xml
identical src/main/resources/logback-spring.xml
identical src/main/resources/i18n/messages.properties
identical src/test/resources/logback.xml
identical src/test/resources/junit-platform.properties
identical mvnw
identical mvnw.cmd
identical .mvn/wrapper/maven-wrapper.jar
identical .mvn/wrapper/maven-wrapper.properties
identical .mvn/jvm.config
identical src/main/docker/jib/entrypoint.sh
identical checkstyle.xml

With Node v20.18.0 finishes with errors and without trying to regenerate the rest of the files:

     info KeyStore '/home/foo20/src/main/resources/config/tls/keystore.p12' already exists. Leaving unchanged.
[@faker-js/faker]: faker.internet.userName() is deprecated since v9.1.0 and will be removed in v10.0.0. Please use faker.internet.username() instead.
✔ applying multi-step templates
     info Using existing git repository.
identical .prettierrc
identical .prettierignore
✔ prettier configuration files committed to disk
✔ loading translations
✔ updating package.json dependencies versions
✔ prettifying sonar-project.properties
✔ adding package-info.java files
✔ sorting pom.xml file
✔ translating angular application
identical sonar-project.properties
identical .husky/pre-commit
identical src/main/resources/banner.txt
identical .devcontainer/Dockerfile
identical pom.xml
identical src/main/resources/logback-spring.xml
identical src/main/resources/i18n/messages.properties
identical src/test/resources/logback.xml
identical src/test/resources/junit-platform.properties
identical mvnw
identical mvnw.cmd
identical .mvn/wrapper/maven-wrapper.properties
identical .mvn/wrapper/maven-wrapper.jar
identical .mvn/jvm.config
identical src/main/docker/jib/entrypoint.sh
identical checkstyle.xml
**ERROR! ERROR! Cannot read properties of undefined (reading 'added')
TypeError: Cannot read properties of undefined (reading 'added')
    at Conflicter._detectConflict (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:182:58)
    at async Conflicter._checkForCollision (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:260:13)
    at async Conflicter.checkForCollision (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:205:20)
    at async Object. (file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:391:36)
    at async file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/p-transform/dist/queue.js:68:28
    at async file:///home/.nvm/versions/node/v20.18.0/lib/node_modules/generator-jhipster/node_modules/p-queue/dist/index.js:187:36**

With Node v18.20.4 finishes with errors and without trying to regenerate the rest of the files:

          info KeyStore '/home/foo18/src/main/resources/config/tls/keystore.p12' already exists. Leaving unchanged.
[@faker-js/faker]: faker.internet.userName() is deprecated since v9.1.0 and will be removed in v10.0.0. Please use faker.internet.username() instead.
✔ applying multi-step templates
     info Using existing git repository.
identical .prettierrc
identical .prettierignore
✔ prettier configuration files committed to disk
✔ loading translations
✔ updating package.json dependencies versions
✔ prettifying sonar-project.properties
✔ adding package-info.java files
✔ sorting pom.xml file
✔ translating angular application
identical sonar-project.properties
identical .husky/pre-commit
identical src/main/resources/banner.txt
identical .devcontainer/Dockerfile
identical pom.xml
identical src/main/resources/logback-spring.xml
identical src/main/resources/i18n/messages.properties
identical src/test/resources/logback.xml
identical src/test/resources/junit-platform.properties
identical mvnw
identical mvnw.cmd
identical .mvn/wrapper/maven-wrapper.jar
identical .mvn/wrapper/maven-wrapper.properties
identical .mvn/jvm.config
identical src/main/docker/jib/entrypoint.sh
identical checkstyle.xml
ERROR! ERROR! Cannot read properties of undefined (reading 'added')
TypeError: Cannot read properties of undefined (reading 'added')
    at Conflicter._detectConflict (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:182:58)
    at async Conflicter._checkForCollision (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:260:13)
    at async Conflicter.checkForCollision (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:205:20)
    at async Object. (file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/@yeoman/conflicter/dist/conflicter.js:391:36)
    at async file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/p-transform/dist/queue.js:68:28
    at async file:///home/.nvm/versions/node/v18.20.4/lib/node_modules/generator-jhipster/node_modules/p-queue/dist/index.js:187:36
Related issues

JHipster generator can't regenerate a jdl change #27866

Suggest a Fix
JHipster Version(s)

8.7.3

Browsers and Operating System

Ubuntu 22.04.2

Environment and Tools

openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7)
OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)

git version 2.34.1

node: v22.11.0
npm: 10.9.0

Docker version 24.0.2, build cb74dfc

  • Tickets opened without reproduction steps or that doesn't follows the template recommendation will be closed.
  • Checking this box is mandatory (this is just to show you read everything)
@mraible
Copy link
Contributor

mraible commented Nov 20, 2024

Can you try with the following command:

jhipster entity Foo --single-entity

@jperezdelafuente
Copy link
Contributor Author

jperezdelafuente commented Nov 20, 2024

When I launch "jhipster entity Foo --single-entity" in an empty directory, I get the following output with Node v18.20.3 (and similar with Node v20.18.0 or Node v22.11.0):

 ~/testfoo/  jhipster entity Foo --single-entity

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝
                            https://www.jhipster.tech
Welcome to JHipster v8.7.3

 _______________________________________________________________________________________________________________

  Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/

  Application files will be generated in folder: /home/geiser/testfoo
 _______________________________________________________________________________________________________________

✔ What is the base name of your application? testfoo
INFO!
The entity Foo is being created.


Generating field #1

✔ Do you want to add a field to your entity? yes
✔ What is the name of your field? fooAttribute
✔ What is the type of your field? String
✔ Do you want to add validation rules to your field? no

================= Foo =================
Fields
fooAttribute (String)


Generating field #2

✔ Do you want to add a field to your entity? no

================= Foo =================
Fields
fooAttribute (String)


Generating relationships to other entities

✔ Do you want to add a relationship to another entity? no

================= Foo =================
Fields
fooAttribute (String)



✔ Do you want to use separate service class for your business logic? Yes, generate a separate service
interface and implementation
✔ Do you want to use a Data Transfer Object (DTO)? Yes, generate a DTO with MapStruct
✔ Do you want to add filtering? Dynamic filtering for the entities with JPA Static metamodel
✔ Is this entity read-only? no
✔ Do you want pagination and sorting on your entity? Yes, with pagination links and sorting headers

Everything is configured, generating the entity...

INFO! Generating entities Foo
✔ Which *type* of application would you like to create? Monolithic application (recommended for simple
projects)
✔ What is your default Java package name? com.mycompany.myapp
✔ Would you like to use Maven or Gradle for building the backend? Maven
✔ Do you want to make it reactive with Spring WebFlux? no
✔ Which *type* of authentication would you like to use? HTTP Session Authentication (stateful, default
Spring Security mechanism)
✔ Besides JUnit, which testing frameworks would you like to use?
✔ Which *type* of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
✔ Which *production* database would you like to use? Oracle
✔ Which *development* database would you like to use? H2 with disk-based persistence
✔ Which cache do you want to use? (Spring cache abstraction) Ehcache (local cache, for a single node)
✔ Do you want to use Hibernate 2nd level cache? yes
✔ Which other technologies would you like to use?
✔ Which *framework* would you like to use for the client? Angular
✔ Besides Jest/Vitest, which testing frameworks would you like to use?
✔ Do you want to generate the admin UI? yes
✔ Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
✔ Would you like to enable internationalization support? yes
✔ Please choose the native language of the application Spanish
✔ Please choose additional languages to install English
✔ applying multi-step templates
✔ prettier configuration files committed to disk
ERROR! An error occured while running jhipster:spring-cache#customizeFiles
ERROR! ERROR! Unable to find /home/testfoo/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java.
Error: Unable to find /home/testfoo/src/main/java/com/mycompany/myapp/config/CacheConfiguration.java.
    at SpringCacheGenerator.editFile (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/base-core/generator.js:1047:23)
    at source.addEntityToCache (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/spring-cache/generator.js:74:30)
    at SpringCacheGenerator.customizeFiles (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/spring-cache/generator.js:168:50)
    at SpringCacheGenerator.executeTask (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:258:26)
    at env.queueTask.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:232:56)
    at runLoop.add.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:395:23)
    at Immediate. (/home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:48:34)
    at process.processImmediate (node:internal/timers:476:21)
    at process.callbackTrampoline (node:internal/async_hooks:128:17)

@jperezdelafuente
Copy link
Contributor Author

jperezdelafuente commented Nov 20, 2024

When I launch "jhipster entity Foo --single-entity" in an empty directory and select "No cache", I get the following output with Node v18.20.3 (and similar with Node v20.18.0 or Node v22.11.0):

 ~/testfoo/ jhipster entity Foo --single-entity

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝
                            https://www.jhipster.tech
Welcome to JHipster v8.7.3

 _______________________________________________________________________________________________________________

  Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/

  Application files will be generated in folder: /home/geiser/testfoo
 _______________________________________________________________________________________________________________

✔ What is the base name of your application? testfoo
INFO!
The entity Foo is being created.


Generating field #1

✔ Do you want to add a field to your entity? yes
✔ What is the name of your field? fooAttribute
✔ What is the type of your field? String
✔ Do you want to add validation rules to your field? no

================= Foo =================
Fields
fooAttribute (String)


Generating field #2

✔ Do you want to add a field to your entity? no

================= Foo =================
Fields
fooAttribute (String)


Generating relationships to other entities

✔ Do you want to add a relationship to another entity? no

================= Foo =================
Fields
fooAttribute (String)



✔ Do you want to use separate service class for your business logic? Yes, generate a separate service interface and implementation
✔ Do you want to use a Data Transfer Object (DTO)? Yes, generate a DTO with MapStruct
✔ Do you want to add filtering? Dynamic filtering for the entities with JPA Static metamodel
✔ Is this entity read-only? no
✔ Do you want pagination and sorting on your entity? Yes, with pagination links and sorting headers

Everything is configured, generating the entity...

INFO! Generating entities Foo
✔ Which *type* of application would you like to create? Monolithic application (recommended for simple projects)
✔ What is your default Java package name? com.mycompany.myapp
✔ Would you like to use Maven or Gradle for building the backend? Maven
✔ Do you want to make it reactive with Spring WebFlux? no
✔ Which *type* of authentication would you like to use? HTTP Session Authentication (stateful, default Spring Security mechanism)
✔ Besides JUnit, which testing frameworks would you like to use?
✔ Which *type* of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
✔ Which *production* database would you like to use? Oracle
✔ Which *development* database would you like to use? H2 with disk-based persistence
✔ Which cache do you want to use? (Spring cache abstraction) No cache - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!
✔ Which other technologies would you like to use?
✔ Which *framework* would you like to use for the client? Angular
✔ Besides Jest/Vitest, which testing frameworks would you like to use?
✔ Do you want to generate the admin UI? yes
✔ Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
✔ Would you like to enable internationalization support? yes
✔ Please choose the native language of the application Spanish
✔ Please choose additional languages to install English
✔ applying multi-step templates
✔ prettier configuration files committed to disk
ERROR! An error occured while running jhipster:liquibase#postWriteChangelogs
ERROR! ERROR! Unable to find /home/testfoo/src/main/resources/config/liquibase/master.xml.
Error: Unable to find /home/testfoo/src/main/resources/config/liquibase/master.xml.
    at LiquibaseGenerator.editFile (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/base-core/generator.js:1047:23)
    at source.addLiquibaseChangelog (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:74:66)
    at LiquibaseGenerator._addLiquibaseFilesReferences (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:499:16)
    at LiquibaseGenerator.postWriteChangelog (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:710:25)
    at file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:462:90
    at Array.map ()
    at LiquibaseGenerator.postWriteChangelogs (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/dist/generators/liquibase/generator.js:462:60)
    at LiquibaseGenerator.executeTask (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:258:26)
    at env.queueTask.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:232:56)
    at runLoop.add.once (file:///home/.nvm/versions/node/v18.20.3/lib/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:395:23)

Copy link
Contributor

github-actions bot commented Nov 20, 2024

Issue check: JHipster has completed the sample check

27944 Value
JDL ✔️
Entities JDL -
--- ---
Application Generation ✔️
Check Status
Frontend check ✔️
Backend check ✔️
E2E check ✔️

This check uses jhipster info or jdl output from the issue description to generate the sample.
Bug report that does not contain this information will be marked as invalid.

app.jdl
application {
  config {
    applicationType monolith,
    baseName foo,
    packageName com.foo,
    jhiPrefix gsr,
    authenticationType session,
    databaseType sql,
    devDatabaseType h2Disk,
    prodDatabaseType postgresql,
    enableHibernateCache true,
    cacheProvider ehcache,
    buildTool maven,
    testFrameworks [cypress, gatling, cucumber],
    clientFramework angular,
    enableTranslation true,
    nativeLanguage es,
    languages [es, en]
    incrementalChangelog true
  }
  entities *
}

/** Entity Foo */

entity Foo(foo) {

/* Foo */
foo String required maxlength(20)

}

dto * with mapstruct

service all with serviceImpl

paginate all with pagination
app-1.jdl
application {
  config {
    applicationType monolith,
    baseName foo,
    packageName com.foo,
    jhiPrefix gsr,
    authenticationType session,
    databaseType sql,
    devDatabaseType h2Disk,
    prodDatabaseType postgresql,
    enableHibernateCache true,
    cacheProvider ehcache,
    buildTool maven,
    testFrameworks [cypress, gatling, cucumber],
    clientFramework angular,
    enableTranslation true,
    nativeLanguage es,
    languages [es, en]
    incrementalChangelog true
  }
  entities *
}

/** Entity Foo */

entity Foo(foo) {

/* Foo */
foo String required maxlength(20)

/* Foo2 */
foo2 String maxlength(20)

}

dto * with mapstruct

service all with serviceImpl

paginate all with pagination

@mshima
Copy link
Member

mshima commented Nov 20, 2024

Node 22 issue will be tracked at #27948.

@mshima
Copy link
Member

mshima commented Nov 20, 2024

This issue is in @yeoman/conflicter package due to diff breaking changes https://github.com/kpdecker/jsdiff/blob/master/release-notes.md#600

@mshima
Copy link
Member

mshima commented Nov 22, 2024

This issue is in @yeoman/conflicter package due to diff breaking changes https://github.com/kpdecker/jsdiff/blob/master/release-notes.md#600

Fix is released in new @yeoman/conflicter version.
Will be part of next JHipster release.

@mshima mshima closed this as completed Nov 22, 2024
@jperezdelafuente
Copy link
Contributor Author

I think the issue is very blocking and should be fixed in a new version 8.7.4 without waiting for 8.8.0 (due to updates to Spring Boot 3.4 and Angular 19)

@mraible mraible added this to the 8.8.0 milestone Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants