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

Spotless 6.0 failures with message to add repositories block, but said block exists #1002

Closed
ZacSweers opened this issue Nov 28, 2021 · 2 comments

Comments

@ZacSweers
Copy link
Contributor

While trying to make a public repro for gradle/gradle#19113 I encountered a different issue where using spotless in a plugins {} block seems to miss any repositories declared.

  • Gradle 7.3
  • Spotless version 6.0.0
  • OS - repros on macOS and linux

Repro PR: slackhq/slack-lints#10

Result:

> Task :spotlessKotlin FAILED
You need to add a repository containing the '[com.pinterest:ktlint:0.41.0]' artifact in 'build.gradle'.
E.g.: 'repositories { mavenCentral() }'

Even though it is present in the build file

plugins {
  id("com.diffplug.spotless") version "6.0.0" apply false
}

// ...

allprojects {
  repositories {
    google()
    mavenCentral() // KtLint is available here!
  }

  apply(plugin = "com.diffplug.spotless")
  configure<SpotlessExtension> {
    // ...
    val ktlintVersion = "0.41.0"
    val ktlintUserData = mapOf("indent_size" to "2", "continuation_indent_size" to "2")
    kotlin {
      target("**/*.kt")
      ktlint(ktlintVersion).userData(ktlintUserData)
      trimTrailingWhitespace()
      endWithNewline()
      licenseHeaderFile(rootProject.file("spotless/spotless.kt"))
      targetExclude("**/spotless.kt")
    }
    kotlinGradle {
      ktlint(ktlintVersion).userData(ktlintUserData)
      trimTrailingWhitespace()
      endWithNewline()
      licenseHeaderFile(
        rootProject.file("spotless/spotless.kt"),
        "(import|plugins|buildscript|dependencies|pluginManagement)"
      )
    }
  }
}
@nedtwigg
Copy link
Member

I think this is a dupe of #993

@ZacSweers
Copy link
Contributor Author

Ah yep seems so. hope the repro is helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants