-
Notifications
You must be signed in to change notification settings - Fork 17
KopyKat Gradle plugin #40
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
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # jitpack.yml
# Conflicts: # buildSrc/build.gradle.kts # gradle/libs.versions.toml # settings.gradle.kts
if (kkSettings.applyKspPlugin.getOrElse(false)) { | ||
target.pluginManager.apply("com.google.devtools.ksp") | ||
} |
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 doesn't seem to apply KSP automatically - I'm not sure why. I'll investigate.
target.configurations.matching { it.name == KspGradleSubplugin.KSP_MAIN_CONFIGURATION_NAME }.configureEach { | ||
defaultDependencies { | ||
add(target.dependencies.create("com.github.kopykat-kt.kopykat:ksp:1.0-rc1")) | ||
} | ||
} |
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.
defining a dependency like this doesn't seem to work. It might need to be a mandatory dependency. I'll investigate.
target.extensions.configure<KspExtension> { | ||
arg("mutableCopy", "${kkSettings.mutableCopy.getOrElse(false)}") | ||
arg("copyMap", "${kkSettings.copyMap.getOrElse(false)}") | ||
arg("hierarchyCopy", "${kkSettings.hierarchyCopy.getOrElse(false)}") | ||
} |
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.
these don't seem to work. If I set copyMap.set(false)
in Gradle, I can still use person.copyMap {}
. I'm not sure if this is a Gradle or KSP thing. I'll investigate.
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.
Note that if kkSettings
sets mutableCopy
(or any other) to null
, then the corresponding argument in KSP should not be set. And in any case, it should be set to true
if nothing is provided.
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.
Good point - I've changed it to only set the KSP arg if the value is not-null.
I think we should be careful with this, and ensure that it doesn’t get harder than the current instructions. My experience with this is that a custom plug-in sometimes fail on Android or MPP, for which KSP has special instructions. |
Yeah, the plugin instructions would be easier if the KopyKat plugin can be published to Maven Central or the Gradle Plugin Portal. JitPack manually overrides the project's group, which in turn breaks the Gradle plugin marker. If published on Maven Central, the The plugin in this PR shouldn't cause problems with Kotlin Multiplatform, but users might have to manually enable KSP per source set. There's ways to test for this though, either manually with example projects, or with Gradle TestKit. I can include them in this PR, if you'd like? But I think that would make it too large. Can you find the special instructions for Android? I could only find them for Kotlin Multiplatform. |
I'm working on publishing to Maven Central (#41), which should make things easier |
- adds some docs for settings - minor code tidy up
… KSP plugin and KopyKat KSP dependency
# Conflicts: # settings.gradle.kts
|
||
gradlePlugin { | ||
val kopyKatGradlePlugin by plugins.creating { | ||
id = "at.kopykat" |
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.
Gh
Here's an initial attempt. It's still a little rough, but it's ready for a first look.
fixes #29
It requires some setup:
Notes: