When I tried to generate an application with a package name contains a reserved Java keyword (in my case "for") no errors occurred but the application can't be run. See the output :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.068 s
[INFO] Finished at: 2020-07-30T14:08:17-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0.0:read-project-properties (default) on project test: Properties could not be loaded from File: sonar-project.properties -> [Help 1]
I replaced "for" by any other word and try to follow Java convention "for_" and the project run like expected (no files are missing in that case)
I think this is expected as in java package names reserved keywords cannot be used. In any case this belongs to the generator repository so I am transferring it there. :smile:
Currently,we use a regexp to validate the full package path:
https://github.com/jhipster/generator-jhipster/blob/master/generators/server/prompts.js#L57-L67
It should probably be replaced or enhanced by a new function in jhipster-core that would iterate on each package and check against reserved keywords using jhiCore.isReservedKeyword(input, 'JAVA')
I my case I only used the online generator. In both case described an archive is generated. I think it could be good to have a client validation to the package name in online generator.
The online generator frontend code uses the same regex: and finally it calls generator-jhipster, so I guess that adding the check in generator-jhipster would make the project generation to fail but I don't know what would be the user experience in this case.
I guess we have to reflect the same regex we put in generator in jhipster-online as well so that it fails and gives the user a proper error message when trying to generate the project in jhipster-online or through cli. This is the reason I transferred this issue. Correct me if I am wrong or if something is needed to be done on the jhipster-online side. :thinking:
Maybe it could be done in two ways : adding a check in generator-jhipster and add a client validation into the online generator frontend to display immediately that the package name is wrong.
It's just ideas ...
Once jhipster/jhipster-core#479 is merged and released, the generator can be updated to validate the package name.
@gmarziou It seems the issue you mentioned is fixed. Can we close this issue?
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 :smiley:.
Comment or this will be closed in 7 days
I completely forgot about this, I have something that is half baked, I must write tests.
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 :smiley:.
Comment or this will be closed in 7 days
Removing stale label, as it's in progress by @gmarziou