Share buildSrc classpath for subproject

I want to configure the extension from my custom plugin

class CustomPlugin : Plugin<Project> {
    override fun apply(project: Project) {
       configureSonar(project)
       project.subprojects{
            it.afterEvaluate {
                it.plugins.apply("my.custom-plugin")
            }
        }
    }

   private fun configureSonar(project: Project) {
      project.pluginManager.withPlugin("org.sonarqube") {
             project.extensions.getByType(SonarQubeExtension::class.java).also { sonar ->
              // my custom props
           }
      }
  }
}

if i have one module it work. But if i have multi module project, i have exeption in configure subproject :

java.lang.NoClassDefFoundError: org/sonarqube/gradle/SonarQubeExtension

I think this problemis due to the fact that classes do not extend into configuration classpath subprojects
i create example project :
Plugin
Application

1 Like