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.

Confusion around kapt's generated option

See original GitHub issue

Trying to use Moshi’s new Kotlin code gen feature, it seems that while the processor runs, the code it generates is going into a black hole somewhere.

It uses kapt’s generated option to know where to generate code. In gradle, this ends up roughly in $buildDir/generated/source/kaptKotlin/main. For kotlin, this seems to go nowhere. Not sure if the option just isn’t being set or what.

Option is normally accessed via processingEnv.options["kapt.kotlin.generated"]

See: https://kotlinlang.org/docs/reference/kapt.html#generating-kotlin-sources

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
thalescmcommented, May 18, 2018

Hey @hzsweers , Kapt can pottentially generate stuff in three different directories: kapt.kotlin.generated option path, which kotlin APs should point out to. sources, which is normally where java APs output appears classes, if you’re generating class or resources files Check more out here.

What happens on buck is that kapt has four steps for running (decribed in the link). But you can not know for sure, while on buck, if it will, or will not generate anything.

  • So we run kapt, which is the file you see at ./buck-out/annotation/libraries/foundation/modelgen/thrifty-utilities/__src_main_kapt_generated__
  • copy the output from those directories to a tmp directory, which is the file you see at ./buck-out/bin/libraries/foundation/modelgen/thrifty-utilities/__src_main_gen_sources__
  • Zip that file and add it to the sources. Kotlinc nor javac accepts zipfiles as entry, so we have to unzip them, and we do that on the project working directory, which is the file you see at ./buck-out/gen/libraries/foundation/modelgen/thrifty-utilities/lib__src_main____working_directory

We should probably delete both files at annotation and bin directories at the and of the step, would be cleaner. To make IDE see the files generated by buck kapt, you could add a config for gradle that src files contain buck-out/path/to/your/project/gen/kapt. The other two paths where they appear are gradle outputs.

Hopefully that cleared how the flow works, but anything else please ask. Answering the final question, that doesn’t mean the processor is being called multiple times. But it does indicate you’re running kapt both with buck and with gradle.

0reactions
ZacSweerscommented, Nov 11, 2018

Hey - it would be great if someone from the buck team could acknowledge this. It’s a major blocker for kotlin-first annotation processors

Read more comments on GitHub >

github_iconTop Results From Across the Web

User Clip: McCain: Travel Ban, Think It Through | C-SPAN.org
How about the next time you do a travel ban, how about thinking it through.
Read more >
Urban Redevelopment around Diridon Station
Urban Redevelopment around Diridon Station. Case Study on Gentrification and Displacement Pressures around. Diridon Station of San Jose, CA.
Read more >
Austronesian Etymologies: IV - jstor
'leaf covering wrapped around fruits to protect them from bats', 12. Ifugao ... sons proposed here are "counterfeit cognates" produced by the fortuitous....
Read more >
The organizational evolution of the international drug trade
This restructuring has produced a move away from formerly hierarchical and tightly controlled organizations, to more loosely coupled and ...
Read more >
Mar 22, 2022 Commissioners Court - Harris County, TX
... FLAG THAT THERE HAS BEEN A LOT OF DISCUSSION AND A LOT OF CONFUSION AROUND THE ROLL OVER POLICY. ... WE ARE...
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