V
V
Vlad Kalyuzhny2020-06-20 21:15:11
gradle
Vlad Kalyuzhny, 2020-06-20 21:15:11

ComponentRegistrar class not called during build?

Hello
There is a project with a custom gradle plugin but when building the compiler module is not responding
I annotated the ComponentRegistrar class with @Autoservice and published in local maven (and it exists) but it is not working
KotlinGradleSubplugin is responding and working however
Thanks in advance

Some code

// Relative path: buildSrc/src/main/kotlin/kt/angular/AngularKtGradleSubplugin.kt
@AutoService(KotlinGradleSubplugin::class)
class AngularKtGradleSubplugin : KotlinGradleSubplugin<AbstractCompile> {

    override fun apply(
        project: Project,
        kotlinCompile: AbstractCompile,
        javaCompile: AbstractCompile?,
        variantData: Any?,
        androidProjectHandler: Any?,
        kotlinCompilation: KotlinCompilation<KotlinCommonOptions>?
    ) = emptyList<SubpluginOption>()

    override fun isApplicable(project: Project, task: AbstractCompile) =
        project.plugins.hasPlugin(AngularKtGradlePlugin::class.java)

    override fun getCompilerPluginId() = "AngularKtPlugin"

    override fun getPluginArtifact() = SubpluginArtifact(
        groupId = "kt.angular",
        artifactId = "compiler",
        version = "0.0"
    )
}

// Relative path: compiler/src/main/kotlin/kt/angular/CommonComponentRegistrar.kt
@AutoService(ComponentRegistrar::class)
class CommonComponentRegistrar : ComponentRegistrar {

    override fun registerProjectComponents(
        project: MockProject,
        configuration: CompilerConfiguration
    ) {
        println("I am alive")
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question