-
Notifications
You must be signed in to change notification settings - Fork 280
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
Add codegen setting governing Kotlin package #194
Conversation
e3a3c91
to
14d21ec
Compare
14d21ec
to
a2af252
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. Did @stackoverflow have any not-yet covered issues?
""" | ||
module my.mod | ||
|
||
class Person { | ||
name: String | ||
age: Int | ||
hobbies: List<String> | ||
friends: Map<String, Person> | ||
sibling: Person? | ||
} | ||
""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised spotless doesn't flag this. Maybe auto-format (there are multiple sites)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is embedded Pkl inside Kotlin, which I don't think Spotless is aware of yet. Unless you mean the Kotlin around it? There are no errors from spotlessCheck
, and spotlessApply
doesn't change anything at this revision.
pkl-codegen-kotlin/src/main/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorOptions.kt
Show resolved
Hide resolved
pkl-gradle/src/test/kotlin/org/pkl/gradle/KotlinCodeGeneratorsTest.kt
Outdated
Show resolved
Hide resolved
pkl-codegen-kotlin/src/test/kotlin/org/pkl/codegen/kotlin/KotlinCodeGeneratorTest.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. You need to rebase main on your branch before we can merge.
f9ade2e
to
0723834
Compare
Adds a setting to the Kotlin code generator which controls the target Kotlin package for codegen. Applied as a prefix to the normal generated package name. The current versions of the `kotlinx.serialization` and `kotlinx.html` libraries are declared dynamically, which causes a failure when refreshing dependencies. To avoid Kotlin metadata build issues, these have been pinned. - feat(codegen): use `kotlinPackage` as prefix for kotlin codegen - feat(gradle): `kotlinPackage` property in gradle plugin - test(codegen): add tests for custom kotlin package - test(gradle): add tests for generating with custom kotlin package Signed-off-by: Sam Gammon <sam@elide.ventures>
0723834
to
b28452c
Compare
@stackoverflow / @holzensp Thank you for the review; I've adopted all suggestions and made all changes requested. There are no lockfile updates in this change anymore so we should be good there as well. |
Wait, hold up; I've found some bugs on my fork. I'll add a few tests and push an update here to fix. Basically, Kotlinpoet is importing generated typealiases without the qualified package path. Easy fix |
@sgammon: did you try setting a Pkl module name instead? The normal way to solve this is to give your Pkl module a fully qualified name. For example:
And this will generate |
@bioball Yes, I'd noticed that, but this applies an unconditional prefix only for Kotlin, which might be needed in some corner cases. For example, in cases where there is no module involved, Pkl uses the root module, but JPMS forbids this. |
This reverts commit 7f404ff. The package is derived from the module name. Having `module com.example.Foo` in Pkl will create Kotlin `package com.example`.
This reverts commit 7f404ff. The package is derived from the module name. Having `module com.example.Foo` in Pkl will create Kotlin `package com.example`. Eventually, we may want to introduce a way to map Pkl names to package names that provides finer controls to the code generator.
Summary
Adds a setting to the Kotlin code generator which acts as a prefix for the target Kotlin package during codegen.
This has been filed on top of #192 to avoid conflicts.
Changelog
kotlinPackage
property in gradle pluginkotlinPackage
as prefix for kotlin codegenkotlinx.html
andkotlinx.serialization