Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the api equivalent for kapt/annotationProcessor?

Tags:

When we have multiple modules in an Android project, for example, we have a mylibrary module, and some other module apps that will include this mylibrary module in the dependency by implementation project(':mylibrary')

Then when we want to add library which will be used for all the modules, we will add the library dependency in the mylibrary's gradle dependency using the api instead of implementation. For example:

api 'com.google.code.gson:gson:2.8.5' 

Sometimes a library need an annotationProcessor to be included in the dependency.

kapt "org.example:example:1.0.1" 

If I want to include this annotation processor in mylibrary's dependency and make it available to multiple modules, what do I use instead of kapt?

like image 510
s-hunter Avatar asked Apr 10 '19 15:04

s-hunter


People also ask

Is kapt deprecated?

app: Original kapt is deprecated. Please add "apply plugin: 'kotlin-kapt'" to your build. gradle. How do I resolve this?

What is kapt used for?

What is KAPT used for? The answer to this is straight, it is used for annotation processing in Kotlin.

What is Kapt annotation in Java?

kapt uses Java compiler to run annotation processors. Some annotation processors (such as AutoFactory) rely on precise types in declaration signatures. By default, kapt replaces every unknown type (including types for the generated classes) to NonExistentClass, but you can change this behavior.

What is the Kapt configuration for androidtest?

If you use annotation processors for your androidTest or test sources, the respective kapt configurations are named kaptAndroidTest and kaptTest. Note that kaptAndroidTest and kaptTest extends kapt, so you can just provide the kapt dependency and it will be available both for production sources and tests.

What is Kapt and why do I need It?

"Kapt is the Kotlin Annotation Processing Tool" you need this, to generate annotated code in compile time you can see more info in this article 1. Kapt is the Kotlin Annotation Processing Tool, and it’s in pretty good shape these days. If you want to be able to reference generated code from Kotlin, you need to use kapt.

Can I use annotation processors in Kotlin projects?

Annotation processors (see JSR 269) are supported in Kotlin with the kapt compiler plugin. In a nutshell, you can use libraries such as Dagger or Data Binding in your Kotlin projects. Please read below about how to apply the kapt plugin to your Gradle/Maven build.


1 Answers

annotationProcessor and kapt dependencies are not transitive and therefore, need to be declared for every module in your project

like image 143
cyberman Avatar answered Oct 02 '22 03:10

cyberman