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
  • n

    Nikky

    01/14/2019, 3:45 AM
    can a annotation processor get the default values of fields ?
    y
    • 2
    • 1
  • t

    thana

    01/19/2019, 1:09 PM
    hi. I added
    id 'org.jetbrains.kotlin.kapt' version '1.3.11'
    to my
    plugins
    block, but it seems the
    kapt
    configuration is still missing. i always get an error
    Could not find method kapt() for arguments [com.github.dzuvic:jtsgen-processor:0.4.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    Any idea?
    g
    • 2
    • 5
  • t

    tddmonkey

    01/25/2019, 2:40 PM
    This should work:
    kapt {
        arguments {
             arg("kapt.kotlin.generated", yourDir)
        }
    }
    g
    • 2
    • 4
  • g

    galex

    01/31/2019, 10:41 AM
    Is there a way to generate kotlin code in an agnostic module in an mpp project? kapt() is not available as it depends on javac
    t
    • 2
    • 2
  • n

    Nikky

    01/31/2019, 10:59 AM
    the interesting bits are in the
    kgl-opengl/build.gradle.kts
    and
    buildSrc
    g
    • 2
    • 3
  • m

    Marc Knaup

    02/03/2019, 11:05 AM
    Does anybody have a good idea how one could use annotations to "indirectly annotate" a class which isn't in your module? I was trying something like this:
    import io.ktor.http.Url
    
    @JSON
    typealias Url = Url
    Then in the annotation processor I could access the aliased type and apply the annotation logic there. Unfortunately that doesn't work with source-only annotations.
    • 1
    • 1
  • j

    jw

    02/07/2019, 3:18 PM
    you likely want a standalone AOP solution like AspectJ
    j
    b
    s
    • 4
    • 3
  • s

    Stéphane Nicoll

    02/21/2019, 5:38 PM
    Hey everyone, I am looking for a sample or best practices to test an annotation processor with Kotlin. I’ve something that works quite well for Java and was wondering how I could do the same with Kotlin (knowing that I’ll probably have to do something kotlin specific in there)
    t
    • 2
    • 16
  • s

    Sam

    02/24/2019, 9:57 PM
    Where are kotlin stdlib's annotation processors defined?
    g
    m
    • 3
    • 23
  • m

    Marc Knaup

    03/01/2019, 8:57 PM
    So like compile-testing is running the Java Compiler for testing annotation processors, can I do similar with kapt? https://github.com/google/compile-testing Or only through command line interface?
    t
    • 2
    • 2
  • m

    Marc Knaup

    03/03/2019, 10:06 PM
    Are there plans to migrate from
    com.sun.tools.javac.main.JavaCompiler
    (etc.) to
    javax.tools.JavaCompiler
    (etc.)? The former causes a lot of issues when using Kapt in-process on Java 9+. … oh, the Kotlin Compiler uses it too 😕
    f
    • 2
    • 1
  • r

    rafaeltoledo

    03/11/2019, 4:15 PM
    Do someone had problems with kapt not running for unit tests in a module?
    a
    j
    • 3
    • 6
  • g

    gildor

    03/14/2019, 8:09 AM
    https://github.com/JetBrains/kotlin/pull/2179
    🎉 2
    l
    t
    • 3
    • 4
  • s

    sam

    03/20/2019, 10:51 PM
    if I add
    kapt "io.arrow-kt:arrow-meta:$arrow_version"
    to jvmMain for example, it complains it doesn't know what kapt is. I guess perhaps that's because the kapt plugin doesn't understand the mpp layout?
    m
    • 2
    • 1
  • j

    juliocbcotta

    03/25/2019, 12:05 PM
    Is it possible to have some kapt dependence declared as API? I have a module with some dagger scopes and I would like to avoid the boiler plate in all modules that depend of that module of declare dagger dependency again.
    g
    • 2
    • 2
  • j

    jw

    03/26/2019, 4:05 PM
    does anyone have an example of passing kapt arguments for a single Android buildType/variant?
    y
    • 2
    • 1
  • e

    Eugen Martynov

    04/12/2019, 9:53 AM
    we use gradle parallel
    y
    • 2
    • 1
  • e

    Eugen Martynov

    04/12/2019, 9:53 AM
    Any thoughts or suggestion?
    t
    h
    • 3
    • 5
  • j

    jw

    04/21/2019, 4:59 PM
    Probably because they're not copied to the stubs
    s
    y
    • 3
    • 3
  • t

    tapchicoma

    04/25/2019, 11:13 AM
    have anyone noticed that
    kapt
    in kotlin
    1.3.30
    picks up wrong build cache entries? In our case build cache is populated only on CI builds and kapt sometimes picks up results from
    master
    branch that has new generated classes and fails local branch build with message "Can't find this new generated class type."
    • 1
    • 1
  • a

    ansman

    04/25/2019, 5:37 PM
    1.3.31 is broken for me, I get this while compiling:
    Execution failed for task ':common:kaptDebugKotlin'.
    > Could not resolve all files for configuration ':common:_classStructurekaptDebugKotlin'.
       > Failed to transform file 'classes.jar' to match attributes {artifactType=class-structure, org.gradle.usage=java-runtime-jars}
          > Execution failed for StructureArtifactTransform: /Users/nicklas/.gradle/caches/transforms-2/files-2.1/3b26390363c49f3a73506646bd39f9c5/jars/classes.jar.
             > java.lang.IllegalArgumentException (no error message)
    y
    a
    • 3
    • 3
  • p

    poohbar

    05/01/2019, 1:21 PM
    Are there any plans to optimize Kapt speed? In recent tests Uber found out that it almost doubles compilation times. I have similar experience in my project where without Kapt the build is significantly faster. https://eng.uber.com/measuring-kotlin-build-performance/
    t
    g
    • 3
    • 2
  • t

    tevjef

    05/02/2019, 3:31 PM
    With the changes made to kapt in 1.3.31, kotlin does some aggressive caching to decrease incremental built times. Unfortunately, some annotation processors and kapt don’t work well together and the cache is not properly invalidated in some conditions. - Deleted classes with
    @Inject
    may still have code generated for it. - Moved classes with
    @Inject
    may still have code generated in the old location. This behavior is enabled by default in Kotlin 1.3.31. Is there something I need to configure to ensure the cache is properly invalidated? This is causing some issues for my team, especially when we switch between branched.
    g
    e
    • 3
    • 5
  • m

    Marc Knaup

    05/09/2019, 1:21 PM
    What did change in recent kapt/Kotlin/Gradle updates which causes that annotation processors are no longer being run when using a
    project
    kapt dependency? old (Gradle 5.2.1, Kotlin 1.3.21)
    kapt(project(":fluid-json-annotation-processor"))
    runs kapt just fine using processor from different subproject new (Gradle 5.4.1 with modules, Kotlin 1.3.31)
    kapt(project(":fluid-json-annotation-processor", "compile"))
    annotation processor is not used anymore and no error 😕
    • 1
    • 2
  • t

    thana

    05/20/2019, 1:04 PM
    are there any example about how to add compiler warnings using kapt?
    b
    • 2
    • 2
  • s

    SnowmanX95

    05/28/2019, 10:58 PM
    Experimenting with annotation processors - is there an easy in way to figure out whether an annotated property is nullable? The mirror APIs don’t have any information on this. I looked a bit into kotlinx metadata library, but I must be using it in a wrong way as all the flags I’m getting back are nullable … (the flag absolute value is 551). Here’s the code I’m using to gather the flags:
    val metadataAnnotation = typeElement.getAnnotation(Metadata::class.java)
            val header = KotlinClassHeader(
                metadataAnnotation.kind,
                metadataAnnotation.metadataVersion,
                metadataAnnotation.bytecodeVersion,
                metadataAnnotation.data1,
                metadataAnnotation.data2,
                metadataAnnotation.extraString,
                metadataAnnotation.packageName,
                metadataAnnotation.extraInt
            )
    
            val metadata = KotlinClassMetadata.read(header)
            when (metadata) {
                is KotlinClassMetadata.Class -> {
                    metadata.accept(object: KmClassVisitor()  {
                        override fun visitProperty(
                            flags: Flags,
                            name: String,
                            getterFlags: Flags,
                            setterFlags: Flags
                        ): KmPropertyVisitor? {
                            val nullable = Flag.Type.IS_NULLABLE(flags)
                            Logger.logW("* visiting property $name, flags: $flags, nullable: $nullable")
                            return super.visitProperty(flags, name, getterFlags, setterFlags)
                        }
                    })
                }
                else -> {
                    Logger.logW("bummer ... not a class: $metadata")
                }
            }
    Anyone can see anything?
    s
    g
    +2
    • 5
    • 19
  • l

    laimiux

    05/30/2019, 12:11 AM
    Anyone using incremental kapt in multi-module setup? I’m noticing that it actually makes build times worse if one of core modules is invalidated. For example, changing a feature module causes 70-90 second kapt in the main app module. (Project has over 50 modules)
    g
    c
    • 3
    • 6
  • r

    rdhruva

    06/10/2019, 11:59 PM
    when I migrate my android project from kotlin 1.3.11 to 1.3.31, all gradle modules that use
    kaptTest
    failing until I
    apply plugin 'kotlin-kapt'
    — is that really necessary? am I doing it right? any idea where i can find documentation / release notes about breaking changes like these? 🙂
    g
    • 2
    • 9
  • i

    Imran/Malic

    06/14/2019, 10:27 AM
    Does anyone know why the gradle Task kaptKotlin may fail ?
    t
    • 2
    • 3
  • m

    Matej Drobnič

    06/16/2019, 9:40 AM
    Is this known issue? It happened when I enabled kapt workers with 1.3.31. Just want to know if this is known before I waste time with creating repro case.
    Is_this_known_issue_.txt
    s
    • 2
    • 7
Powered by Linen
Title
m

Matej Drobnič

06/16/2019, 9:40 AM
Is this known issue? It happened when I enabled kapt workers with 1.3.31. Just want to know if this is known before I waste time with creating repro case.
Is_this_known_issue_.txt
s

Sergey Chelombitko

06/16/2019, 2:22 PM
Are you on JDK 11+ or 8?
m

Matej Drobnič

06/16/2019, 7:39 PM
I think I'm on 11+, will have to double check tomorrow when I reach the machine in question
s

Sergey Chelombitko

06/16/2019, 8:29 PM
there was a bug due to missing tools.jar in newer JDKs that got fixed in 1.3.40
m

Matej Drobnič

06/17/2019, 5:07 AM
is the fix in the EAP?
s

Sergey Chelombitko

06/17/2019, 8:38 AM
yes
m

Matej Drobnič

06/17/2019, 9:28 AM
thanks, will check that out and report later today
It was actually Java 10 and 1.3.40 seems to have fixed the issue. Thanks for your input!
View count: 1