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 7.1.0 import-jdl (or jdl) command regenerate all existing entity #1 #15967

Closed
duonglv1993 opened this issue Aug 14, 2021 · 6 comments
Closed

Comments

@duonglv1993
Copy link

duonglv1993 commented Aug 14, 2021

Overview of the issue

When you define new entities in .jdl (in my case I named it is app.jdl) file, then use jhipster import-jdl (or jdl) command to generate entity, all existing entities will be regenerated (expected only new entities will be generated). I try use jhipster jdl --skip-regenerate app.jdl, but jhipster still regenerate all entities.

Motivation for or Use Case

Jhipster (7.1.0) seems that default is to regenerate all entities, but when I use --skip-regenerate option, it cannot help. In my previous project, I use jhipster 6.8.0, it doesn't regenerate existing entities (only generate new entities or modifies entity).

Reproduce the error
  1. Create new application with Jhipster 7.1.0.
  2. Create new file app.jdl with one entity (eg: employee entity name), then use jhipster jdl app.jdl to generate entity.
  3. Add more new entity to app.jdl (eg: department entity name), the use jhipster jdl app.jdl, now both new entity (department) and existing entity (employee) are generated (expected only one department entity is generated).
Related issues

.

Suggest a Fix

.

JHipster Version(s)

Jhipster 7.1.0

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "baseName": "issuejhipster",
    "jhipsterVersion": "7.1.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": ["cypress"],
    "blueprints": [],
    "otherModules": [],
    "pages": [],
    "creationTimestamp": 1628835510026,
    "serviceDiscoveryType": false,
    "reactive": false,
    "authenticationType": "jwt",
    "packageName": "com.issuejhipster",
    "serverPort": "8080",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "buildTool": "maven",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "react",
    "withAdminUi": true,
    "clientTheme": "none",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "com/issuejhipster",
    "jwtSecretKey": "",
    "devServerPort": 9060,
    "clientPackageManager": "npm",
    "clientThemeVariant": "",
    "languages": ["en"],
    "entities": ["Employee"],
    "lastLiquibaseTimestamp": 1628836693000
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Employee (employees) {
  name String maxlength(50) required
  email String required
  birthDate Instant required
}
dto * with mapstruct
paginate * with pagination
service * with serviceClass

Environment and Tools

java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

git version 2.22.0.windows.1

node: v12.18.4

npm: 6.14.6

Docker version 20.10.7, build f0df350

docker-compose version 1.29.2, build 5becea4c

Entity configuration(s) entityName.json files generated in the .jhipster directory
{
  "name": "Employee",
  "fields": [
    {
      "fieldName": "name",
      "fieldType": "String",
      "fieldValidateRules": ["maxlength", "required"],
      "fieldValidateRulesMaxlength": "50"
    },
    {
      "fieldName": "email",
      "fieldType": "String",
      "fieldValidateRules": ["required"]
    },
    {
      "fieldName": "birthDate",
      "fieldType": "Instant",
      "fieldValidateRules": ["required"]
    }
  ],
  "relationships": [],
  "entityTableName": "employees",
  "dto": "mapstruct",
  "pagination": "pagination",
  "service": "serviceClass",
  "jpaMetamodelFiltering": false,
  "fluentMethods": true,
  "readOnly": false,
  "embedded": false,
  "applications": "*",
  "changelogDate": "20210813063813"
}
Browsers and Operating System

OS: Windows 10 64-bit

@Tcharl
Copy link
Contributor

Tcharl commented Aug 14, 2021

Why is it an issue? it is the expected behaviour since it keeps everything consistent.
If you don't want some of your entities to be regenerate, say 'skip' when it asks to override you entities or add the relative path to a .yo-resolve file at the root of your project. e.g.
src/main/java/corp/domain/MyEntity.java skip

@duonglv1993
Copy link
Author

duonglv1993 commented Aug 15, 2021

Why is it an issue? it is the expected behaviour since it keeps everything consistent.
If you don't want some of your entities to be regenerate, say 'skip' when it asks to override you entities or add the relative path to a .yo-resolve file at the root of your project. e.g.
src/main/java/corp/domain/MyEntity.java skip

resource files, service files,... must be customized according to your own business. it's never really exactly the same as the generated file.
say skip override don't have skip all option, I have a lot of generated files in my project (more than 1000 files), I have to enter n 1000 times to say skip override files. I think it's really unreasonable.
I see jhipster jdl command have --skip-regenerate option, but it doesn't work in my case.

@jasonmarco
Copy link
Contributor

jasonmarco commented Aug 16, 2021

Your issue seems to be related to mine: #15366

As a workaround, you can add either the skipClient, or skipServer properties to each of your entity json files in the .jhipster folder. When Jhipster regenerates everything it will read these values, and not generate the client or server code. Please note that if you use skipClient, entity models for the front-end may not be generated; you'll have to write them yourself.

{
  "name": "FooEntity",
  "skipClient": true,
  "skipServer": false,
  "changelogDate": "20210730201049"
}

@mshima
Copy link
Member

mshima commented Aug 18, 2021

--skip-regenerate is a jhipster 6 option that don't rewrites identical files, triggering a webpack rebuild, it's enabled by default at jhipster 7.
See jhipster --help.

You can use globs at .yo-resolve.
src/main/java/corp/domain/** skip

@github-actions
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity.
Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted.
We are accepting PRs 😃.
Comment or this will be closed in 7 days

@pascalgrimaud pascalgrimaud added this to the 7.3.1 milestone Oct 19, 2021
@Tcharl
Copy link
Contributor

Tcharl commented Oct 23, 2021

Wrote a tips regarding code customization: https://github.com/jhipster/jhipster.github.io/pull/1171/files
Could help you also, to avoid customizing hundred of generated files.

Bests

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

6 participants