Zach G
02/13/2025, 10:06 PMRupesh Bansal
02/16/2025, 9:45 PMDaniel Pejcinovski
02/18/2025, 3:00 PMcontainingFile
for every KSClassDeclaration
I find that matches my criterion, and setting the aggregating
flag to true.
I also wrap each KSClassDeclaration
in a KSTopDownVisitor
to write my data.
As far as I understand KSP, this should be everything necessary to not reprocess the classes in future runs, but I can see that it runs multiple times and as soon as it does it causes a fileAlreadExistsException
.
Any ideas?Zac Sweers
02/21/2025, 3:39 AMRobert Jaros
02/21/2025, 6:13 PMACTUAL_WITHOUT_EXPECT
compiler error suppression. I'm using this suppression on the actual class, for which the corresponding expect class is generated by the KSP plugin. This suppression allows opening the clean project in the IDE without errors, even before the KSP processor is executed. Unfortunately my request was just declined by the compiler team with a suggestion to forward the problem to the KSP team. So can I ask for your suggestions on how to solve this problem?Robert Jaros
02/26/2025, 6:52 PM2.1.20-RC-1.0.30
.Daniel Pejcinovski
03/04/2025, 1:03 PMbuild/generated/ksp/metadata/common/kotlin/MyGeneratedFile.kt
and an additional in build/generated/ksp/jvm/jvmMain/kotlin/MyGeneratedFile.kt
.
This is fine and good, but now I want to use the generated files, and I just can't figure out how to add it as a dependency or source sets.
I'm using the following to add it as a dependency:
dependencies {
add("kspCommonMainMetadata", project(":myProcessors"))
add("kspJvm", project(":myProcessors"))
add("kspJvmTest", project(":myProcessors"))
}
Again, this works, and is what gets me the files when I build.
However, I use Kotlin MPP specific annotations when generating the files, such as @JsExport
and @JsStatic
, which aren't processable on the JVM platform and I get Declaration annotated with '@OptionalExpectation' can only be used in common module sources
errors.
If I remove the KspJvm
and KspJvmTest
lines I only get unresolved
errors and the processor does not run on building.
There is something I'm just not getting here, any ideas?Jason Dusek
03/04/2025, 6:15 PMDmitry Stakhov
03/07/2025, 7:53 AMPlease upgrade ksp or downgrade kotlin-gradle-plugin
rad
03/09/2025, 11:35 AMCodeGenerator#createNewFileByPath
where it will sometimes just throw a FileAlreadyExistsException
:
public class AxiProcessor(
env: SymbolProcessorEnvironment,
) : SymbolProcessor {
private companion object Identifiers {
const val COMMAND: String = "net.radstevee.axi.core.command.Command"
}
private val gen: CodeGenerator = env.codeGenerator
override fun process(resolver: Resolver): List<KSAnnotated> {
val services = mutableListOf<String>()
// ...
gen.createNewFileByPath(
Dependencies(false),
"META-INF/services/$COMMAND",
""
).use { out ->
OutputStreamWriter(out, StandardCharsets.UTF_8).use { writer ->
services.forEach { svc ->
writer.write(svc)
writer.write("\n")
}
}
}
return emptyList()
}
}
[ksp] kotlin.io.FileAlreadyExistsException: /home/radsteve/dev/axi/example/build/generated/ksp/main/resources/META-INF/services/net.radstevee.axi.core.command.Command
at com.google.devtools.ksp.common.impl.CodeGeneratorImpl.createNewFile(CodeGeneratorImpl.kt:154)
at com.google.devtools.ksp.common.impl.CodeGeneratorImpl.createNewFileByPath(CodeGeneratorImpl.kt:78)
at net.radstevee.axi.ksp.AxiProcessor.process(AxiProcessor.kt:63)
How can I prevent this? Because I am not creating the file multiple times. The whole processing logic is also only checking for annotated declarations and adding onto the services
list. If I just wrap the createNewFileByPath
call in a try/catch, the file does get created but is just empty. I can't directly remove it since I don't know where it will be located. This doesn't happen if I clean build of courseDenis Stepanov
03/10/2025, 8:18 AM.class
files and not seing them on the classpath https://github.com/google/ksp/issues/2365 That's how we do it in Micronaut but it looks like KSP2 is having some kind of issue with. Any idea what can be wrong?eygraber
03/10/2025, 2:50 PMeygraber
03/12/2025, 4:47 AMRemi Latapy
03/14/2025, 3:35 PM@Replacing("androidx.compose.material3")
to enforce design system use in Compose. I don't see how to do it in pure Lint rulejbarr
03/19/2025, 9:12 PMartifacts.zip
for 2.1.10-1.0.31? bazel's rules_kotlin uses these for compilationeygraber
03/20/2025, 4:25 PMZach G
03/31/2025, 1:22 PMRTAkland
04/01/2025, 2:54 PMRTAkland
04/03/2025, 11:38 AMNitesh Singh
04/04/2025, 11:25 AMNitesh Singh
04/04/2025, 11:25 AMForrest Pangborn
04/10/2025, 1:32 PMTypeName
instances from KType
values, using the asTypeName()
extension to KType
provided by KotlinPoet.
Looks like the implementation of asTypeName()
relies on kotlin-reflect
(the typeParameters
property on KClass
).
In KSP1, using asTypeName()
like this works but with KSP2 I’m getting an exception:
Caused by: kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:88)
at kotlin.jvm.internal.ClassReference.getTypeParameters(ClassReference.kt:38)
at com.squareup.kotlinpoet.ParameterizedTypeName$Companion.get$kotlinpoet(ParameterizedTypeName.kt:236)
at com.squareup.kotlinpoet.ParameterizedTypeNames.asTypeName(ParameterizedTypeName.kt:275)
My processor already includes kotlin-reflect
as an implementation dependency – and I've tried adding it for the consumer of the processor too, but same failure.
Running with latest KSP version but in legacy mode (via useKsp2 = false
) works fine as well – so seems definitely an issue with KSP2.
Anyone have any suggestions on other things I can try?Tomáš Procházka
04/14/2025, 10:35 AMtrevjones
04/14/2025, 9:23 PMuseKSP2
and found you had given them a nudge on what appears to be my last blocker now. Any chance there is a more stable API we can ask the moshi maint team to look at now?Denis Stepanov
04/23/2025, 1:08 PMAru Jeganathan
04/24/2025, 5:56 PMOlivier Notteghem
04/28/2025, 11:39 PMJake Woods
05/01/2025, 12:33 AMsealed class KonvertResult<out T, out E> {
data class Ok<out T>(val value: T) : KonvertResult<T, Nothing>()
data class Err<out E>(val error: E) : KonvertResult<Nothing, E>()
}
I'm getting a reference to it's constructor in ksp like this:
private val okConstructor = resolver
.getClassDeclarationByName<KonvertResult.Ok<*>>()
?.getConstructors()
?.firstOrNull()
In ksp1 when I run okConstructor.returnType
I get Ok<T>
. But in ksp2 when I return okConstructor.returnType
I get Ok<*>
. Is there any way I can get back to Ok<T>
?Zac Sweers
05/07/2025, 8:01 PMJP Sugarbroad
05/08/2025, 7:50 PM