Brad Mace
Brad Mace

Reputation: 27886

Use gradle plugin in parent project's buildSrc

How can a subproject in a multiproject Gradle build use a Gradle plugin that's defined in the root project's buildSrc folder?

I've basically got:

and I'm trying to apply the plugin in the common project:

apply plugin: 'com.example.conventions.JavaConventionsPlugin'

but it says

Plugin with id 'com.example.conventions.JavaConventionsPlugin' not found.

Upvotes: 1

Views: 2548

Answers (1)

Brad Mace
Brad Mace

Reputation: 27886

Looks like the plugin layout is different in buildSrc and I should have been following this example: https://docs.gradle.org/current/samples/sample_convention_plugins.html

  • buildSrc/build.gradle
  • buildSrc/settings.gradle
  • buildSrc/src/main/groovy/example.java-conventions.gradle
  • buildSrc/src/main/groovy/com/example/conventions/JavaConventionsPlugin.groovy

and applying using:

plugins {
    id 'example.java-conventions'
}

Upvotes: 1

Related Questions