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

Generating a Kotlin project with a package name containing keywords will result in an unusable project #1555

Closed
wants to merge 6 commits into from

Conversation

Ant00000ny
Copy link
Contributor

fix #1550

Initializer does not escape package names containing kotlin keywords, and generates unusable project. This fix checks for hard keywords (from offcial doc, Kotlin does not provide method like javax.lang.model.SourceVersion#isKeyword in Java)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 31, 2024
@mhalbritter mhalbritter self-assigned this Aug 5, 2024
@mhalbritter
Copy link
Contributor

Hey, thanks for the PR. I think there's something missing: i just tested with the package name package.class.fun.example and expected package, class and fun to be escaped. However, the resulting package name is com.example.demo and there's this note in the readme:

* The original package name 'package.class.fun.example' is invalid and this project uses 'com.example.demo' instead.

I think the code in io.spring.initializr.metadata.InitializrConfiguration#hasReservedKeyword is interfering with that. It still works under the assumption that the Java keywords apply to every other language.

@mhalbritter mhalbritter added the status: waiting-for-feedback We need additional information before we can continue label Aug 5, 2024
@Ant00000ny
Copy link
Contributor Author

Thank you. I'm not sure if it is ok to just add a parameter isKotlin to io.spring.initializr.metadata.InitializrConfiguration#cleanPackageName amd skip Java keyword checks for Kotlin in this method?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 6, 2024
@mhalbritter mhalbritter changed the title Handling kotlin package names with keywords Generating a Kotlin project with a package name containing keywords will result in an unusable project Aug 7, 2024
@mhalbritter mhalbritter added type: bug and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Aug 7, 2024
mhalbritter pushed a commit that referenced this pull request Aug 7, 2024
@mhalbritter
Copy link
Contributor

Thank you very much and congratulations on your first contribution 🎉!

I've polished the changes a bit in bce08cf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generating a Kotlin project with a package name containing keywords will result in an unusable project
3 participants