i did.. now i am getting this: `e: /home/nikky/dev...
# kapt
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
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?
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 ?
So problem solved? What do you mean does nothing? As I see your AP just doesn't generate any code
it should print me the annotation it processes.. but no logging
Should print where? I don't think that you will see those logs in Gradle on default log level
i did when i was using annotationProcessor
Just to check that your code runs, add assert there or write to some file
assert does not fire.. and i have to go.. seeya later
But error from above was definitely from kapt. Maybe you changed some config
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..
Copy code
roundEnv: [errorRaised=false, rootElements=[], processingOver=true]
Are you sure that have classes annotated with this annotation?
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
the annotation processor in
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
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
it does .. i checked.. but i gues i will just copy that into the META-INF then
I saw your message that now everything works, but you just has problem with logging
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
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
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?
Copy code
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
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
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
throws for me
val fileObj = processingEnv.filer.createResource(StandardLocation.CLASS_OUTPUT, "", "config/test.json")
throws this:
Copy code
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
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
Why do you write logfile to jar?
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..
Did you check info log level?
ok that shows the logs at least.. i guess there is no reason for a logfile then