diff --git a/build.gradle b/build.gradle index 59a8319f94c..c82c3c4f42d 100644 --- a/build.gradle +++ b/build.gradle @@ -114,6 +114,31 @@ task installGitHooks(type: Copy, dependsOn: 'setLocalRepo') { into localRepo + "/hooks" } +spotless { + // Resolve the spottless plugin dependencies from the buildscript repositories rather than the + // project repositories. That way the spotless plugin does not use the locally built version of + // checker-qual as a dependency. Without this, errors like the follow are issued when running + // a spotless task without a locally-built version of checker-qual.jar: + // Could not determine the dependencies of task ':checker-qual:spotlessCheck'. + // > Could not create task ':checker-qual:spotlessJavaCheck'. + // > Could not create task ':checker-qual:spotlessJava'. + // > File signature can only be created for existing regular files, given: + // /Users/smillst/jsr308/checker-framework/checker-qual/build/libs/checker-qual-3.25.1-SNAPSHOT.jar + predeclareDepsFromBuildscript() +} + +spotlessPredeclare { + // Put all the formatters that have dependencies here. Without this, errors like the following + // will happen: + // Could not determine the dependencies of task ':spotlessCheck'. + // > Could not create task ':spotlessJavaCheck'. + // > Could not create task ':spotlessJava'. + // > Add a step with [com.google.googlejavaformat:google-java-format:1.15.0] into the `spotlessPredeclare` block in the root project. + java { + googleJavaFormat() + } +} + allprojects { tasks.withType(JavaCompile).configureEach { options.fork = true @@ -196,6 +221,8 @@ allprojects { } spotless { + // If you add any formatters to this block that require dependencies here, then you must also + // add them to spotlessPredeclare block. format 'misc', { // define the files to apply `misc` to target '*.gradle', '*.md', '.gitignore'