Java-platform question


I’m currently converting an ant project to gradle. There 40 something subprojects (all java) and one root project. I read about the java-platform plugin and now I’m trying to define the dependency versions with a platform project.

Configuration in the root project:

plugins {

subprojects {
    apply(plugin = "java")

If I add a project with an “java-platform” plugin applied, I get an error the project can only use “java” or “java-platform”

Does this mean, that I have to move the apply(plugin = “java”) to every subproject except the platform project or do I misunderstand how the platform project is used?

Best regards

Hi, I can’t call myself an expert but here’s one idea :slight_smile:

The ‘subprojects’ block is a way of making common specifications across all sub-projects, but if one of those contradicts another specification (like a plugin) in a given sub-project, then I can think of two solutions:

  1. As you suggest, stop applying the plugin centrally, and instead repeat it in each sub-project (except the ones that need to be different)

  2. Make an exception in the top-level project for the sub-projects that need to be different

The second option could be done by replacing the subprojects { block with something like this:

    def javaProjects = subprojects - project(":myJavaPlatformProject")
    configure (javaProjects) {
        apply plugin: 'java'

(Shown in Groovy flavour, adjust as necessary for Kotlin script.)

thanks for the help!
In the end, I did it a little different:

if (this.project == project(":platform")) {

it’s not pretty, but it works