Closed martin-g closed 4 years ago
Thanks for reporting this issue! I or someone else will look into it
The step to reproduce are incorrect, and that was how you described your issue that made me understand the issue... There is no bug here: if you first generate your app with the CLI then create a JDL file with an app definition there, it will obviously use default values because they weren't specified in the JDL.
We could take into account an existing .yo-rc.json
when generating an app. That implies modifying the JDL file where the bare JDL app definition is to complete it, and that's something I don't wanna do because overriding what an user writes is just wrong: the user should have complete control over what's generated.
Thanks for the answer, @MathieuAA ! But then how am I supposed to add entities to my application ? https://www.jhipster.tech/jdl/getting-started does not explain this use case.
If I remove
application {
// config {}
entities *
}
from entities.jh then the import does nothing.
The only way I was able to add entities is by duplicating the config settings in entities.jh
> application
> config
. But this looks wrong to me.
1) why do I need to add them again if they are already in .yo-rc.json
2) the syntax in .yo-rc.json
and in .jh
files is different and it is not just a copy/paste operation.
The issue is that having differences between a Yeoman config file and a JDL isn't supported. I'm open to suggestions because it the first time (if my memory doesn't fail me) that this use case is reported.
I'll think of something, and reopening this...
I guess I miss something obvious. Could you please explain what is the normal workflow of using JDL after application creation ?
I'd imagine something like:
1) use jhipster
to generate an application. Here I answer all the questions and those are saved in .yo-rc.json
.
2) use jhipster import-jdl someFile.jh
to add entities to my newly created application
Here I miss what I should put in the application > config
part of someFile.jh
.
The only way I was able to use import-jdl
is by manually map all settings from .yo-rc.json
to someFile.jh
. If this is the right way then I suggest this ticket to be converted to a feature request. jhipster import-jdl
could use the values from .yo-rc.json
or at application creation time jhipster
could save one more config file if .yo-rc.json
is purely Yeoman thing and should not be consumed by JHipster.
To avoid the manual mapping I even tried jhipster export-jdl exported.jh
hoping that this will create a JDL file with the application config to which I will just add my entities and relationships and then import it. But it does not create exported.jh
at all. Maybe because I have no existing entities so far. Is this a separate issue ?
Instead of using the CLI to generate your app, you can use the JDL. If you define your app in the JDL but don't have the same options in your .yo-rc
& JDL file, then it's normal you have the issues you mentioned.
I see. Thanks for clarifying this! I'll let to you (the JHipster maintainers) decide what to do with this issue. Maybe you can just improve the documentation explaining the way JDL importing is supposed to be used.
Maybe this needs better covering
@martin-g Have you tried exporting to a JDL file and then using this base JDL file to further customize your application? (with entities for instance)
I'm doing some tests, that's why I ask you this.
Okay this is tricky.
From now on, JCore supports existing apps and reads info in them.
This is done by passing the application
attribute in the importer configuration. The other properties, except forceNoFiltering
, are deprecated and will be removed in v8.
Right now, passing an app configuration takes more precedence than the other attributes.
As a workaround on this issue: exporting to JDL and modifying the exported JDL file works. This is not needed anymore though.
Overview of the issue
I have generated an application with the help of
jhipster
command line tool. At application generation time I've answered all questions and my application was successfully generated. All answers of the questions are properly saved in .yo-rc.json file!Later I've decided to add some new entities to my existing application, so I've used
jhipster import-jdl entities.jh
command. entities.json looks like:The problem that I face, and I believe is a bug, is that the importer overrides the values in .yo-rc.json. For example at application generation time I've selected MongoDB as a database but now JHipster
import-jdl
command overrides the value tosql
, because this is the default, I guess.In my opinion
jhipster import-jdl
should use the values from.yo-rc.json
if there are no customconfig
settings inentities.jh
file, not to override them with the defaults.Or I need to copy the answers from
.yo-rc.json
toentities.json
> application > config ?Motivation for or Use Case
N/A
Reproduce the error
jhipster
and select some non-default options, e.g. MongoDB as a databasejhipster import-jdl entities.json
git diff .yo-rc.json
and see that the original answers are changedRelated issues
I was not able to find a ticket for this issue.
Suggest a Fix
import-jdl
command should use the values from.yo-rc.json
and override them only if there is anoption
in the .jdl fileJHipster Version(s)
6.4.1
JHipster configuration
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
openjdk version "1.8.0_232-ea" OpenJDK Runtime Environment (build 1.8.0_232-ea-8u232-b09-0ubuntu1-b09) OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)
git version 2.20.1
node: v11.12.0
npm: 6.12.0
yeoman: 3.1.0
Docker version 17.12.0-ce, build c97c6d6
docker-compose version 1.22.0, build f46880fe
Entity configuration(s)
entityName.json
files generated in the.jhipster
directorySee above
Browsers and Operating System
N/A