Skip to content

Bug: Directory 'build/spotless/spotlessKotlin' specified for property 'spotlessOutDirectory' does not exist #741

Closed

Description

@erikhuizinga
  • summary of problem
$ ./gradlew check

...

FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':{myModuleName}:spotlessKotlinCheck' (type 'SpotlessCheck').
> Directory '{pathToProject}/{myModuleName}/build/spotless/spotlessKotlin' specified for property 'spotlessOutDirectory' does not exist.
  • gradle or maven version

Gradle 6.7.1

  • spotless version

Spotless 5.8.2

  • operating system and version

macOS 10.14.6 (18G6042)

  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
spotless {
    format 'misc', {
        target '**/*.gradle', '**/*.properties', '**/*.md', '**/.gitignore', '**/*.yml'
        trimTrailingWhitespace()
        indentWithSpaces()
        endWithNewline()
    }
    kotlin {
        ktlint()
    }
}
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace

See summary above.

Activity

  1. erikhuizinga commented on Nov 20, 2020

    @erikhuizinga
    Author

    The problem is solved if I specify Kotlin targets:

    diff --git a/build.gradle b/build.gradle
    index 80187b5..442ebe2 100644
    --- a/build.gradle
    +++ b/build.gradle
    @@ -122,6 +122,7 @@ subprojects {
                 endWithNewline()
             }
             kotlin {
    +            target '**/src/**/*.kt', '**/src/**/*.kts'
                 ktlint()
             }
         }
  2. erikhuizinga commented on Nov 20, 2020

    @erikhuizinga
    Author

    Now the problem has solved itself. 😕
    I was running 'CtrlCtrl gradle check Enter' from Android Studio. That lead to the problem above. When running ./gradlew check from CLI there was no issue. (???) Then, when running it from AS again, the issue was gone. (???) Even when doing a Gradle clean (which removes the missing directory) before check doesn't reproduce the issue.

    I'm confused.

  3. nedtwigg commented on Nov 20, 2020

    @nedtwigg
    Member

    Interesting. Each format has three tasks. In your case, there is spotlessKotlin, spotlessKotlinCheck, and spotlessKotlinApply.

    The job of spotlessKotlin is to check the formatting of target, and write the correctly formatted result into build/spotless/spotlessKotlin. The spotlessKotlin task has up-to-date checking, buildcache, etc.

    The other two tasks, check and apply, just look at the build/spotless/spotlessKotlin directory, but they do not support up-to-date, buildcache, etc. Well, they kind of do, but only in that spotlessKotlin does all of the actual computation and work, and then check and apply just interpret that result.

    For a clean build, the directory needed by spotlessKotlinCheck and spotlessKotlinApply does not exist, because it is created by spotlessKotlin.

    @OutputDirectory
    public File getOutputDirectory() {
    return outputDirectory;
    }

    @PathSensitive(PathSensitivity.RELATIVE)
    @InputDirectory
    public File getSpotlessOutDirectory() {
    return spotlessOutDirectory;
    }

    @PathSensitive(PathSensitivity.RELATIVE)
    @InputDirectory
    public File getSpotlessOutDirectory() {
    return spotlessOutDirectory;
    }

    Since check and apply don't have any outputs (as far as Gradle is concerned), I wonder if we should not declare any inputs either... @bigdaz any thoughts on this?

  4. nedtwigg commented on Dec 3, 2020

    @nedtwigg
    Member

    Related to this, we should enable support for @IgnoreEmptyDirectories when used on Gradle 6.8+

  5. added a commit that references this issue on Jan 4, 2021
    f8ca1aa
  6. added a commit that references this issue on Jan 4, 2021
    445a88d
  7. nedtwigg commented on Jan 4, 2021

    @nedtwigg
    Member

    Fixed in plugin-gradle 5.9.0

  8. erikhuizinga commented on Jan 4, 2021

    @erikhuizinga
    Author

    Thanks, I'll try it ASAP and you'll hear from me if anything's wrong (but I don't expect any issues 😉).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions