question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use Kotlin Annotation Processor

See original GitHub issue
  • Add kapt to gradle project
    id "org.jetbrains.kotlin.kapt" version "1.3.72"
  • Use some annotation processor e.g.
kapt "com.google.auto.service:auto-service:1.0-rc7"
  • Boom image

Full stacktrace

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
natanfudgecommented, May 14, 2020

After hours of trial and error, reverse engineering, and debugging, I have figured out the solution. Simply add the following to your build.gradle:

def kaptConfig = configurations.getByName("kapt")
kaptConfig.extendsFrom(configurations.minecraftNamed)
kaptConfig.extendsFrom(configurations.modCompileClasspathMapped)
kaptConfig.extendsFrom(configurations.mappingsFinal)

def loomExt = extensions.getByType(LoomGradleExtension)
def javaTask = tasks.getByName("compileJava")

kapt {
    arguments {
        arg("inMapFileNamedIntermediary", loomExt.getMappingsProvider().tinyMappings.getCanonicalPath())
        arg("outMapFileNamedIntermediary", loomExt.getMappingsProvider().mappingsMixinExport.getCanonicalPath())
        arg("outRefMapFile", new File(javaTask.getDestinationDir(), loomExt.getRefmapName()).getCanonicalPath())
        arg("defaultObfuscationEnv", "named:intermediary")
    }
    includeCompileClasspath = false
}


dependencies {
    kapt "net.fabricmc:sponge-mixin:0.8+build.18"
    kapt "net.fabricmc:fabric-mixin-compile-extensions:0.3.0.4"
}

Global solution TBD

1reaction
natanfudgecommented, May 14, 2020

Wow, that actually did it. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin Annotation Processor not working? What am I missing?
Recently I've been trying to make a annotation processor through Kotlin but I can't seem to get it ...
Read more >
Using kapt | Kotlin
Using kapt · Using in Gradle · Annotation processor arguments · Gradle build cache support · Improving the speed of builds that use...
Read more >
Misleading "Cannot run plugin annotation processor ... - GitHub
The annotation processor is separate from SpongeGradle, and generally works without it. If you run into this error, all extended functionality ...
Read more >
[Solved]-Kotlin annotation processor: can't make it work-kotlin
In my practices, AutoService just ignore kotlin classes. You have to use a java class instead, or write your own META-INF:.
Read more >
The Guide To Your First Annotation Processor with KSP (And ...
In this article, we are going to create a KSP-based annotation processor that generates new code and files based on annotation usages.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found