https://kotlinlang.org logo
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
benchmarks
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
confetti
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
lincheck
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
Title
n

Nikky

01/13/2019, 2:16 AM
i did.. now i am getting this:
e: /home/nikky/dev/fabric/config/build/tmp/kapt3/stubs/main/config/CottonConfig.java:6: error: incompatible types: NonExistentClass cannot be converted to Annotation
g

gildor

01/13/2019, 2:32 AM
So now it looks that your config is correct, Kapt is running, but you have some issue on classpath
Add this to gradle.properties to get real error message instead of NonExistentClass kotlin.incremental.usePreciseJavaTracking=true
Also, are you sure that you have those annotation in AP classpath?
n

Nikky

01/13/2019, 2:36 AM
i have them in a seperate subproject that i added to implementation and kapt
and the annotationprocessor subproject also depends o nthem
and i fixed this error.. now it works.. but does nothing ?
g

gildor

01/13/2019, 2:39 AM
So problem solved? What do you mean does nothing? As I see your AP just doesn't generate any code
n

Nikky

01/13/2019, 2:40 AM
it should print me the annotation it processes.. but no logging
g

gildor

01/13/2019, 2:42 AM
Should print where? I don't think that you will see those logs in Gradle on default log level
n

Nikky

01/13/2019, 2:43 AM
i did when i was using annotationProcessor
g

gildor

01/13/2019, 2:43 AM
Just to check that your code runs, add assert there or write to some file
n

Nikky

01/13/2019, 2:45 AM
assert does not fire.. and i have to go.. seeya later
g

gildor

01/13/2019, 2:59 AM
But error from above was definitely from kapt. Maybe you changed some config
n

Nikky

01/13/2019, 5:01 AM
there was the annotation i wanted in the subproject but there was a file in the main project i nthe same place, ssame name but contents commented out
that messed it up since that loaded first
so now i pipe stdout into a file and get a log that way.. and i see that kapt gives me 0 classes..
roundEnv: [errorRaised=false, rootElements=[], processingOver=true]
g

gildor

01/13/2019, 9:17 AM
Are you sure that have classes annotated with this annotation?
n

Nikky

01/13/2019, 9:17 AM
it works on java classes when i run it via anotationProcessor and remove the kapt plugin
i pushed my current progress to here.. its just PoC project anyways.. https://github.com/NikkyAI/cotton-config
annotations are in
annotation
the annotation processor in
annotationProcessor
the root project uses the annotation processor
thats where i use it: https://github.com/NikkyAI/cotton-config/blob/7aff95d0879aad2381e0e2d4fe5b87fb187cbd05/src/main/kotlin/config/KottonKonfig.kt#L9 those and more are marked as supported on the annotation processor
g

gildor

01/13/2019, 9:24 AM
Maybe you have some problem with auto factory execution, register your processor manually instead using auto factory, maybe problem with nested kapt run
Also check that AF actually generated metainf for you
n

Nikky

01/13/2019, 9:43 AM
it does .. i checked.. but i gues i will just copy that into the META-INF then
g

gildor

01/13/2019, 9:58 AM
I saw your message that now everything works, but you just has problem with logging
n

Nikky

01/13/2019, 10:18 AM
it seems like i was not noticing before. .the file i thought was getting log written to did nto change.. kapt seems to be unale to write to anywhere outside of the provided
"kapt.kotlin.generated"
option
now i am trying to find a way to have the annptation processor work the same for running with annotationProcessor and with kapt
i just want to write resource files anyway.. no java or kotlin sourcefiles
g

gildor

01/13/2019, 10:41 AM
Not sure what you mean, because all annotation processors that I know written for APT and don't have any kapt specific changes, because this is a way how kapt works, it's transparent for AP
What kind error do you have if you try to write to file outside of this dir?
n

Nikky

01/13/2019, 10:54 AM
e: [kapt] An exception occurred: java.io.IOException: No such file or directory
	at java.io.UnixFileSystem.createFileExclusively(Native Method)
	at java.io.File.createNewFile(File.java:1012)
	at config.ConfigProcessor.process(ConfigProcessor.kt:72)
...
using normal annotationprocessor i can write anywhere
also apparently kapt does not add any other filetypes to the jar.. only .kt files are getting compiled in.. i might need some extra tasks to move files around then
g

gildor

01/13/2019, 11:33 AM
This is not a job of kapt to add files to jar, only generate + kapt has own source set for kotlin generated files
But not anything else, you have to write to some existing source set
n

Nikky

01/13/2019, 8:51 PM
well the problem still stands.. kapt does process nothing even though i use the annotations in java and kotlin code.. for now i tried to look at google's autojson code since i know that one worked in kapt but for some reason the same code for opening a
FileObj
throws for me
val fileObj = processingEnv.filer.createResource(StandardLocation.CLASS_OUTPUT, "", "config/test.json")
throws this:
e: error: FATAL ERROR: javax.annotation.processing.FilerException: Attempt to reopen a file for path /home/nikky/dev/fabric/cotton-config/build/tmp/kapt3/classes/main/config/test.json
  	at com.sun.tools.javac.processing.JavacFiler.checkFileReopening(JavacFiler.java:535)
  	at com.sun.tools.javac.processing.JavacFiler.createResource(JavacFiler.java:431)
  	at config.ConfigProcessor.processImpl(ConfigProcessor.kt:100)
  	at config.ConfigProcessor.process(ConfigProcessor.kt:43)
  	at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:99)
so for some reason i am getting FIleObjects that are not open for writing.. i have to compare this to annotationProcessor behaviour
the lack of logging is really annoying me..though i can attach a debugger and found it it does run.. 2 times in fact i guess the last one is for test sources and ofc it finds nothing there
y

yan

01/14/2019, 1:43 PM
n

Nikky

01/14/2019, 10:30 PM
it works now.. assuming all annotations are actually available to both the annotation processor, compilation and kapt configuration but that does not fix the logging right ? or the fact that the kapt plugin in gradle hides stdout or blocks filesystem access outside of the "intended" folders ?
it would be really nice if i did not have to write a logfile into the produced jar.. i might need a extra gradle taks just to remove it again on release
g

gildor

01/14/2019, 11:19 PM
Why do you write logfile to jar?
n

Nikky

01/14/2019, 11:24 PM
because i cannot write to stdout the messager provided by the annotation processing envirnment does nothing and i cannot write anywhere else
usually you would expect this to work right ?
processingEnv.messager.printMessage(Diagnostic.Kind.NOTE, msg)
it seems to be the right thing to do.. most annotation processing libraries like google's autoService also uses this.. but in kapt they are not printing anything either..
g

gildor

01/15/2019, 12:57 AM
Did you check info log level?
n

Nikky

01/15/2019, 3:15 AM
ok that shows the logs at least.. i guess there is no reason for a logfile then