https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

Jey

03/05/2024, 3:16 PM
Hey can someone tell how can I exclude class from being included to final build, I exclude class from jar and everything is ok but it's being included to klib and it causes linkage error (because it's has been provided by different source)
m

Michael Krussel

03/05/2024, 5:57 PM
You could have the code that doesn't go in the final release in a different folder. Then you configure the source sets such that on regular builds you include that folder, but on the final release you don't.
j

Jey

03/05/2024, 8:51 PM
I've tried to create stub file and used property that should be generated in that file through ksp, with jvm target works great since I can exclude file from jar easily, but other targets get error on linkage phase since in klib file still exists. Idk how can I exclude file/package from sources in some way that will not ruin compilation
m

Michael Krussel

03/05/2024, 8:56 PM
Somewhere with in your build script the output directory where KSP puts that generated file gets added the the source directories. I don't remember if KSP automatically does that or if you manually did it. You need to add some flag to the build that will script that step or skip that KSP task altogether. Then it shouldn't be in the list of sources built when creating the klib (might need to do a clean to remove it from the build dir). Now if that file is actually needed for compiling, then this won't work and I'm not sure why you would want to remove it from the final build.
j

Jey

03/05/2024, 10:17 PM
I have a ksp plugin that uses annotations to generate certain resources (actually its output being generated from library user sources). Which my library uses for its internal logic, since ksp cannot update existing resources I generate a file in which I need a variable that contains the generated resources.
2 Views