rciovati
01/06/2020, 4:47 PMafterEvaluate
Kapt doesn’t run. Any idea? Here the example:
class MyPlugin : Plugin<Project> {
override fun apply(project: Project) {
with(project) {
val extension = extensions.create("projectConfiguration", MyExtension::class.java)
// Adding the dependency in the apply works
addDependency("kapt", "library-coordinate")
// If the dependency is added in the afterEvaluate block kapt doesn't run.
// :myproject:dependencies shows the dependency properly
afterEvaluate {
if (extension.value) {
addDependency("kapt", "library-coordinate")
}
}
}
}
private fun Project.addDependency(configuration: String, dependency: String) {
dependencies.add(configuration, dependency)
}
}
tapchicoma
01/07/2020, 7:15 PMafterEvaluate {}
is discouraged to use for plugin development for quite a long timetapchicoma
01/07/2020, 7:18 PMafterEvaluate { .. }
for adding kapt dependency? To add it only when kapt plugin is applied?rciovati
01/09/2020, 2:08 PMafterEvaluate{}
, but I haven’t found another way to read the actual extension value. Do you have any suggestion?tapchicoma
01/09/2020, 2:14 PMproject.plugins.withId("org.jetbrains.kotlin.kapt") { your action that depends on kapt }
rciovati
01/09/2020, 2:35 PMwithId
seems very helpful (actually it solves something else :D) but I’m not how that would solve this issue. I’m sure already that whatever I’m try to do already happens the plugin has appliedtapchicoma
01/09/2020, 2:36 PMrciovati
01/09/2020, 2:37 PMrciovati
01/09/2020, 2:38 PMmyExtension {
useDagger = true
}
and when userDagger
is true
I’ll add Dagger dependencies to the project.tapchicoma
01/09/2020, 2:40 PMproject.plugins.withId("org.jetrains.kotlin.kapt") {
if (project.extenstions.getByType(MyExtension.class).useDagger) {
add dagger
}
}
tapchicoma
01/09/2020, 2:42 PMrciovati
01/09/2020, 2:42 PMrciovati
01/09/2020, 2:49 PMtapchicoma
01/09/2020, 3:03 PMtapchicoma
01/09/2020, 3:07 PMrciovati
01/09/2020, 3:14 PMtapchicoma
01/09/2020, 3:14 PM