Home > OS >  How to apply a Gradle plugin to the root project only?
How to apply a Gradle plugin to the root project only?

Time:04-18

I wrote a Gradle plugin that automatically update our microservices' versions when we do a pull request in Bitbucket, and it works well. It just updates a version=x.y.z key/value pair in the gradle.properties file.

However, I only want to apply it to the root project. How do I do that? Right now I have this in my build.gradle file

allprojects {
    apply plugin: 'jacoco'
    apply plugin: UpdaeVersionPlugin
}

I've tried project, root, rootProject, rootproject, etc instead of allprojects.

CodePudding user response:

Apply external Plugin to a subset of subprojects did not directly answer my question, but it did contain the syntax I was looking for. It's

gradle.rootProject {
    apply plugin: UpdaeVersionPlugin
}
  • Related