https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
kapt
  • g

    grandstaish

    06/16/2020, 7:58 PM
    Does anyone know why some generated files wouldn’t show up in the
    generated/source/kapt
    folder, even though they are being generated? (They’re in the AAR and final APK of my app)
    t
    • 2
    • 8
  • r

    rdhruva

    06/29/2020, 11:46 PM
    hi everyone! we're running into problems in our android gradle builds because of NPEs being thrown from kapt. what is the best way to report such issues? 🙂
    g
    • 2
    • 3
  • i

    iseki

    07/31/2020, 3:42 PM
    Hello, even I use
    kapt{ annotationProcessor("foo.bar.Aprocessor") }
    . The gradle show me that Can't find annotation processor. Before that, I use
    kapt/compileOnly("com.google.auto.service:auto-service:1.0-rc7")
    in the processor build file. And use
    kapt/compileOnly(project("codegen", "default"))
    in the parent project (which use the annotation in fact.) Thank you for your help.
    😫 2
    ✔️ 1
    f
    • 2
    • 15
  • i

    iseki

    08/01/2020, 9:54 AM
    Can I access Kotlin meta information from AnnotationProcessor? I think it's an useful feature. Is it useful? Thank you
    m
    • 2
    • 1
  • a

    Arpan Sarkar

    09/02/2020, 2:29 PM
    What is the simplest way to debug a kotlin annotation processor?
    e
    g
    • 3
    • 4
  • r

    rbares

    11/12/2020, 12:48 PM
    Working on an Android library using Gradle, Kotlin and a 3rd-party codegen plugin using kapt, is there a way to have kapt generate sources but to prevent these files being included in the module build artifacts? I am hoping to be able to split the kapt output into a separate AAR (dependent on the original library), avoiding a trail of unnecessary dependencies for those who don't need the generated classes.
    • 1
    • 1
  • e

    Eugen Martynov

    11/30/2020, 10:15 AM
    It breaks our compilation now with this example
    interface ListOptionsInterface : Serializable {
        val caption: Int
    }
    
    @Parcelize
    data class PreferenceOptionModel<T : ListOptionsInterface>(
            var options: T,
            var isSelected: Boolean = false
    ) : Parcelable
    I can not also find details about this change in CHANGELOG
    d
    • 2
    • 2
  • e

    Eugen Martynov

    11/30/2020, 3:21 PM
    Should I move it to plugins? Should I delete it since I already found an issue and added comments
    m
    • 2
    • 1
  • b

    bod

    12/24/2020, 10:32 AM
    Hello, World! I'm trying to investigate which processors we're using that are not incremental. We used to have a warning about this, but I don't see it anymore. I'm kind of following this article[1] about this, so I'm enabling verbose logs and start a build like this:
    ./gradlew clean :app:assembleDebug -Pkapt.verbose=true --no-build-cache
    I don't see the
    Incremental KAPT support is disabled
    log (I'm certain we used to have it some time ago). But I do see a bunch of
    Incremental annotation processing (apt mode): false
    which worries me. Does this mean it's disabled? (We do have
    kapt.incremental.apt=true
    in our
    build.properties
    ). 💡 Ideas? [1] https://medium.com/@daniel_novak/making-incremental-kapt-work-speed-up-your-kotlin-projects-539db1a771cf
    m
    • 2
    • 4
  • t

    Timo Gruen

    01/22/2021, 3:02 PM
    Hi All, I’m currently keep struggling with the error reports when using a Processor with KAPT and Gradle. When anything fails I’m only receiving a message like
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':connector:example:connector-confluence-cloud:kaptKotlin'.
    > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
       > java.lang.reflect.InvocationTargetException (no error message)
    The processor has been written by myself, so I can change something on that end, but I’m not finding any solution for that. I keep logging using
    processingEnv.error()
    but can’t find any results in the actual log. Is there any way to improve the logging here? Thanks in advance!
    • 1
    • 1
  • m

    Michal Klimczak

    02/02/2021, 9:56 PM
    what are the differences between
    kapt
    and
    kaptKotlin
    directories in
    generated/source
    ? When should I use one or the other? Can't really find anything about it. Dagger and moshi seem to generate to
    kapt
    . From my tests it seems that I need to manually tell gradle where to look for these files for either of these (via
    kotlin.srcDir("${buildDir.absolutePath}/generated/source/kapt/")
    or
    kotlin.srcDir("${buildDir.absolutePath}/generated/source/kaptKotlin/")
    . Yet it doesn't seem to be necessary for dagger etc. If that makes any difference, I'm asking about kotlin multiplatform module.
    t
    • 2
    • 6
  • l

    Luca Piccinelli

    03/22/2021, 2:12 PM
    Hello everyone! Could please anyone point me to a detailed documentation on how to use Kapt server side, possibly with maven? I found a lot of articles but they are all Android oriented....
    t
    g
    • 3
    • 11
  • l

    Luca Piccinelli

    03/24/2021, 9:06 AM
    hey there i'm trying to learn Kapt annotation processing. I have this toy project, with a
    @TestAnnotation
    , a
    Hello
    class annotated, and a
    TestProcessor
    that generates a new class named "<AnnotatedClassName>_Banana" with a method
    eat
    , in this case
    Hello_Banana
    . Everything is in place correctly, and from maven it works just fine. How should I let Intellij use the annotation processor as well? I tried like in the second screendshot but with no luck... Thank you in advance you for your help
    • 1
    • 5
  • t

    Timo Drick

    04/11/2021, 12:18 AM
    Hi, is it possible to get the source file of the code where an annotation is used inside of an annotation Processor? So e.g. i do have the file main.kt and there is my annotation attached to the main function. Is it posiible to get the path and file name of that file inside of my Processor?
    y
    • 2
    • 18
  • t

    TwoClocks

    04/16/2021, 7:18 PM
    Not sure if this is the correct place to ask : I can't seem to get the incremental annotation processor to work w/ kapt. I'm setting 
    kapt.incremental.apt=true
     in the props file but I get this message when gradle runs : 
    Incremental annotation processing (apt mode): false
     I don't get any errors about processors that are not incremental. Any idea of where to look? I'm using kotlin & kapt version 1.4.32
    • 1
    • 1
  • i

    iseki

    04/25/2021, 10:17 AM
    Are there any library can resolve the default value of a parameter? Thank you. I know it might be an AST or something. I only need it for documents.
    t
    • 2
    • 14
  • s

    Stephan Schroeder

    04/26/2021, 11:36 AM
    has someone a good tip for a kapt tutorial for serverside annotation processing? (Android is not involved in any way. The task is to generate a documentation file containing which classes contain certain annotations. Since it's Kotlin files we're talking about, I guess that kapt is the right tool for the job!?)
    t
    t
    • 3
    • 9
  • m

    Michael Böiers

    05/05/2021, 11:24 AM
    I’m using kapt to generate JPA metadata annotations. It works fine when I run it with JDK 15, but it fails with JDK 16. Any thoughts? I’m running it from maven, using the 1.5.0 kotlin plugin. Both jdks are AdoptOpenJDK.
    t
    • 2
    • 1
  • s

    Sha Sha Chu

    05/11/2021, 10:24 PM
    Is there any way in 1.4+ to figure out why kapt is non-incremental for a build? I searched previous messages and people suggest downgrading to 1.3x which is basically impossible in our app
    e
    a
    • 3
    • 13
  • e

    eduardog3000

    05/18/2021, 8:19 PM
    How do I make a simple annotation processor? No Android, just JVM, Kotlin, and Kapt. The only doc page I can find (https://kotlinlang.org/docs/kapt.html) doesn't really say anything about actually making a processor.
    :not-kotlin: 1
    e
    • 2
    • 4
  • h

    hho

    05/27/2021, 6:36 PM
    When kapt complains, that it can't find a
    tools.jar
    (which is correct, because I'm not using Java 8 anymore) – what doesn't work then? Any way to suppress that warning (I'm using Maven)?
    a
    m
    • 3
    • 7
  • d

    dsvoronin

    09/02/2021, 9:33 PM
    Hello, i'm trying
    kapt.classloaders.cache.size
    option, and have really nice results: KaptWithoutKotlincTask: Found 243 tasks executed in 243 projects totaling 6m 59.605s (without cache) Found 243 tasks executed in 243 projects totaling 2m 3.507s (with cache) my question: is 250 a sane number for cache.size option? it says
    # use the same value as the number of modules that use kapt
    but something tells me that it might be an overkill, or it's ok?
    t
    z
    • 3
    • 9
  • z

    Zac Sweers

    09/08/2021, 12:52 AM
    Hi folks - I wrote a (potentially spicy) writeup requesting a roadmap for Kapt and voicing some concern about its seemingly adhoc current maintenance. I hope it lands well - https://youtrack.jetbrains.com/issue/KT-48661
    👍 2
    👀 2
    t
    • 2
    • 1
  • m

    magnumrocha

    09/17/2021, 3:50 PM
    hello guys, is anyone having this Issue?
    java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext (in unnamed module @0x50148e28) cannot access class com.sun.tools.javac.util.Context (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x50148e28
    I am having this after update gradle to version 7.2…
    :youtrack: 1
    z
    p
    • 3
    • 18
  • s

    Slackbot

    11/29/2021, 8:13 AM
    This message was deleted.
    j
    • 2
    • 2
  • r

    Robert

    01/15/2022, 8:21 AM
    Hey. can someone help to to understand what that means:
    implementation fileTree(dir: "lib", include: "*.jar")
    Execution failed for task ':kaptKotlin'.
    > Could not resolve all files for configuration ':_classStructurekaptKotlin'.
       > Failed to transfor Some.jar to match attributes {artifactType=class-structure, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
          > Execution failed for StructureTransformAction: /lib/some.jar.
             > java.lang.IllegalArgumentException (no error message)
    Is this a gradle or kapt issue?
    🎉 1
    • 1
    • 1
  • a

    ankushg

    02/08/2022, 7:59 PM
    Recently ran into an issue where someone accidentally reintroduced kapt into a module that we’d intentionally migrated fully onto KSP Is there a way to disable/block kapt so we can avoid similar issues in the future?
    b
    t
    r
    • 4
    • 6
  • z

    Zac Sweers

    03/18/2022, 6:24 AM
    Maintenance mode doesn't inherently mean deprecated or discontinued or replaced. There are better and faster alternatives out there if you're willing to drop java support, but kapt was always about bridging java processors to kotlin
    ➕ 3
    l
    • 2
    • 1
  • r

    Rohan Maity

    06/08/2022, 7:54 AM
    Does kotlin-kapt 1.6 support java 14?
    t
    • 2
    • 15
  • m

    martmists

    07/13/2022, 11:34 AM
    How would I set up gradle to include resources generated by kapt in the processResources task? My attempt was
    tasks {
        val kaptKotlin by named<Kapt>("kaptKotlin") {
    
        }
    
        val processResources by named<ProcessResources>("processResources") {
            from(kaptKotlin.outputs)
        }
    }
    But that gives
    Task with name 'kaptKotlin' not found in project ':myproject'
    , and I think this would also include any classes generated to resources
    t
    • 2
    • 3
Powered by Linen
Title
m

martmists

07/13/2022, 11:34 AM
How would I set up gradle to include resources generated by kapt in the processResources task? My attempt was
tasks {
    val kaptKotlin by named<Kapt>("kaptKotlin") {

    }

    val processResources by named<ProcessResources>("processResources") {
        from(kaptKotlin.outputs)
    }
}
But that gives
Task with name 'kaptKotlin' not found in project ':myproject'
, and I think this would also include any classes generated to resources
t

tapchicoma

07/13/2022, 2:53 PM
probably you need to wrap your script into
plugins.withId("org.jetbrains.kotlin.kapt") { .. }
m

martmists

07/13/2022, 4:01 PM
is that required separate from the
kotlin("kapt")
in the
plugins {}
block at the top of my build.gradle.kts file?
t

tapchicoma

07/13/2022, 5:35 PM
put it inside your
build.gradle.kts
after
plugins {..}
block:
plugins { .. }

plugins.withId("org.jetbrains.kotlin.kapt") {
    tasks....
}
View count: 31