https://kotlinlang.org logo
#ksp
Title
# ksp
e

Edoardo Luppi

03/21/2024, 12:02 AM
Maybe dumb question. But, can I output generated files into another Gradle project's build dir? Let's say I have two projects:
Copy code
root/
  one
  two
two
depends on
one
. Now, I'd like
one
to generate an interface that can be used in
two
. However that interface should only be available in
two
. Or can I move the KSP generation in
two
and look up annotated classes of
one
?
👀 1
j

Jiaxiang

03/21/2024, 5:39 PM
it is across different gradle projects? Then I don’t think you should do that, you can write one off build script to move file with absolute path if you really want, but that is on your own, much like moving the file manually with file explorer.
e

Edoardo Luppi

03/21/2024, 6:06 PM
it is across different gradle projects
Yup! And what about looking up project `one`'s classes by package name from project
two
, is it possible with KSP? This less manual scripting/custom tasks I have, the better.
I've found this issue https://github.com/google/ksp/issues/1075 Maybe that's what I need to do?
a

Arjan van Wieringen

03/25/2024, 8:27 PM
Why not just add this generated directory as sources via Gradle?
e

Edoardo Luppi

03/25/2024, 8:28 PM
That actually seems like a pretty good idea
Need to verify if I can make it work
a

Arjan van Wieringen

03/25/2024, 8:29 PM
It is the simpler solution I’d say.
e

Edoardo Luppi

03/25/2024, 8:32 PM
Yeah. But then I'd ask, why not just outputting it in the default source set?
I get that the separation is cleaner, but still a valid question
a

Arjan van Wieringen

03/25/2024, 8:34 PM
Because you don’t want to mix actual sources with generated sources
But that’s my 2 cents
e

Edoardo Luppi

03/25/2024, 8:34 PM
Makes sense know that I recalled I'm versioning my code lol
m

mbonnin

03/25/2024, 8:37 PM
Not sure how similar it's to your use case but I've had success generating sources in resources in 1 that module 2 can extract and compile
There's some amount of Gradle required, it's here if you want to take a look
e

Edoardo Luppi

03/25/2024, 8:39 PM
So basically you've implemented a "manual" move operation. Correct?
m

mbonnin

03/25/2024, 8:39 PM
Yes, kind of. The nice thing is that it survives publishing, etc...
module1.jar is self contained
The bad thing is that kmp doesn't have resources 😅
In all cases, I think you'll have to do some Gradle magic
🥲 1
e

Edoardo Luppi

03/25/2024, 8:45 PM
At this point I have more Kotlin code for Gradle than actual production sources
😂 1
true story 1
2 Views