Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
6 tasks done
erikhuizinga opened this issue Nov 20, 2020 · 6 comments · Fixed by #771
Closed
6 tasks done

Comments

@erikhuizinga
Copy link

  • 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.

@erikhuizinga
Copy link
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()
         }
     }

@erikhuizinga
Copy link
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.

@nedtwigg
Copy link
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?

@nedtwigg
Copy link
Member

nedtwigg commented Dec 3, 2020

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

@nedtwigg
Copy link
Member

nedtwigg commented Jan 4, 2021

Fixed in plugin-gradle 5.9.0

@erikhuizinga
Copy link
Author

erikhuizinga commented Jan 4, 2021

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants