Skip to content

Commit

Permalink
Fix problem with configuring the Spotless plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
smillst authored and wmdietl committed Oct 10, 2022
1 parent 83d0ba2 commit 74e4441
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions build.gradle
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 74e4441

Please sign in to comment.