I made a custom multiplatform plugin similar to t...
# ksp
j
I made a custom multiplatform plugin similar to this one https://github.com/google/ksp/tree/main/examples/multiplatform it works great but now I’m a bit lost on how I can publish it as a maven package so I can reuse it in other projects. Is that even doable?
j
the most straightforward way is to publish it to maven local repository so that you can reference your processor by adding
mavenLocal()
to your gradle repository directives.
m
What kind of plugin? (I am also currently dig into Compiler Plugins, so I am super curious)
y
It is not a plugin, it is just a regular maven java artifact. If you are asking for the gradle plugin that adds publishing tasks, these docs should help: https://docs.gradle.org/current/userguide/publishing_maven.html
j
I know how to you the maven plugin thing, that’s not a problem 🙂 I just wonder if it is possible to publish a plugin the same way regular libraries are published on mvncentral, github packages or whatever. So I don’t need to recreate the different processor classes in each of my project that need it
I called it a plugin but that might not be the correct name? I made a ksp “thing” generating extension functions for enum class. It work in my project, how do I make a library/plugin whatever that allows me to use that functionality in other projects?
j
by plugin do you mean a KSP processor? (assuming so since this is the KSP channel) If so, you can publish your processor in whichever way you like, you can refer to other KSP processors on how they publish their artifacts.
you can refer to the link Yigit provided to add
maven-publish
plugin to your project and use Gradle to publish it as maven artifact, the easiest way to use it in another project is to publish it into maven local repository and use it on same machine.
j
Yes, I meant ksp processor, sorry. I tried that to do that, but I’m not sure which module should contain the maven-publish plugin, it should be the “processor” module right? (style based on the ksp multiplatform example) My problem is that when importing the plugin in other multiplatform project, I end up with error saying the processor project is missing targets (since it only has “jvm”) and if I had other target then I have issues with file creation. Should I replace
OutputStream
API by another one that supports multiplatform? You can see my project here if it helps to understand what I’m saying https://github.com/BeiningBogen/SerialName