Latest spotless and gradle fails to recognize gradle 'build' task

4.8k views Asked by At

Just migraded a project to latest gradle, jdk and spotless 6.3.0.

It's a multi-module project, where a sample of te root gradle.build file is:

plugins {
    id 'com.diffplug.spotless' version '6.3.0' apply false
}
...

subprojects {
    apply plugin: 'com.diffplug.spotless'
    spotless {
        java {
            googleJavaFormat('1.14.0')
        }
    }
}
....

build.finalizedBy task1

The problem is that after the upgrade, I am getting:

> Could not get unknown property 'build' for root project 'foo1' of type org.gradle.api.Project.

With exactly the same build.gradle file, only with the old versions id "com.diffplug.gradle.spotless" version "3.27.1" apply false and googleJavaFormat('1.7') it has no problems

any idea ?

1

There are 1 answers

0
Alex On

actually, it had nothing to do with spotless... but leaving this here just in case someone else bumps in the problem

while I can't fully explain what was happening that is working with the older version of spotless, the 'magical' fix was to include 'base' plugin under plugins section..

plugins {
    id 'base' 
    id 'com.diffplug.spotless' version '6.3.0' apply false
}
...

subprojects {
    apply plugin: 'com.diffplug.spotless'
    spotless {
        java {
            googleJavaFormat('1.14.0')
        }
    }
}
....

build.finalizedBy task1