google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.89k stars 274 forks source link

How would I use "Kotlin Symbol Processing API" from maven #47

Open dibog opened 4 years ago

dibog commented 4 years ago

The example showed gradle as build tool, how would you use it with maven?

neetopia commented 4 years ago

I haven't tried maven yet, but Gradle is using maven repositories, and the artifacts are on google maven repository, it should work out of box on maven. You need to add google maven repository to your project and use artifact ID "org.jetbrains.kotlin:kotlin-symbol-processing-api:1.4-M1-dev-experimental-20200610".

neetopia commented 4 years ago

But for using the processors you write in maven, this will be non-trivial as currently there is only gradle plugin support.

jamal-ahmad commented 3 years ago

Not sure if this falls under the same question but currently i'm using KSP to process some JAXB generated classes:

would the KSP generated classes be visible/usable by the consumer of the JAR?

jamal-ahmad commented 3 years ago

Following up on this. If i package up the XJC generated classes and the KSP generated classes and install the package into my local .m2, then i'm able to access all generated artifacts (XJC and KSP) in both maven and gradle project without modifying the source sets.

teras commented 2 years ago

@i-walker There is this project in github, which does exactly this. https://github.com/Dyescape/kotlin-maven-symbol-processing I tried it and works and the solution seems easy and clean. I have zero idea how it is done though. My problem is, that I need to add a parameter and I don't find a way to do it. Any ideas?

i-walker commented 2 years ago

Thanks @teras it worked fine 🙌🏾

teras commented 2 years ago

For future reference: it's even possible to add options. The documentation of kotlin-maven-symbol-processing has been updated to demonstrate just this.

jamal-ahmad commented 2 years ago

@i-walker There is this project in github, which does exactly this. https://github.com/Dyescape/kotlin-maven-symbol-processing I tried it and works and the solution seems easy and clean. I have zero idea how it is done though. My problem is, that I need to add a parameter and I don't find a way to do it. Any ideas?

I haven't tested this myself, but please feel free to close the issue if the solution works. I've ported my projects to gradle and no longer need maven support. Regardless though, i'm happy this works 🙂

BreimerR commented 1 year ago

Anyone have an existing sample on github?

evanchooly commented 1 year ago

@BreimerR https://github.com/MorphiaOrg/critter/blob/master/tests/maven/kotlin/pom.xml#L51

linde9821 commented 4 weeks ago

I am trying to use a custom KSP processor in a Maven project.

But for using the processors you write in maven, this will be non-trivial as currently there is only gradle plugin support.

Is this still true?

And I also tried using kotlin-maven-symbol-processing suggested by @evanchooly However, when I do this, I get the following error:

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:2.0.21:compile (compile) on project XYZ: Compilation failure
[ERROR] There are some plugins incompatible with language version 2.0:
[ERROR]   com.google.devtools.ksp.KotlinSymbolProcessingComponentRegistrar
[ERROR] Please use language version 1.9 or below

This project also seems to be no longer maintained.