This message was deleted.
# community-support
s
This message was deleted.
c
I guess adding it in the plugin works, but that seems, wrong
Copy code
repositories {
  mavenCentral()
}

spotless {...
f
I am not 100% sure but could it be related to a similar I issue I had before? https://gradle-community.slack.com/archives/CAHSN3LDN/p1704732710961099?thread_ts=1704728486.463129&cid=CAHSN3LDN
in your buildSrc, you load dependency here, which seems pointing to here, and what I learned is that when loading a plugin “into your plugins”, then the dependency is a bit tricky and needs to be changed. So that
"com.diffplug.spotless:spotless-plugin-gradle:6.+"
might need to be
"com.diffplug.spotless:spotless-plugin-gradle.gradle.plugin:6.+"
? But I could be totally wrong…. 🙂 Ignore me if so 🙂
e
wait is the plugin creating its own configuration and resolving it?
that unfortunately does require every project it's in to have the repository set up, which is something you shouldn't do from the plugin
using centralized
dependencyResolutionManagement
can help, as long as no plugins or subproject break conventions and start mucking around with repositories on their own
c
@ephemient I tried adding it to
dependencyResolutionManagment
that did nothing
e
it won't help if anything in the project (or its plugins) is touching repositories directly
in that case, you're stuck with modifying repositories in each project
c
any chance you could do me a favor and file a bug with them for me? since I feel you understand the issue far better
e
a bug with who? I don't see it as a spotless bug, although if they don't call out that you need
mavenCentral()
or equivalent repository in their documentation, they should
c
I mean, isn't it kind of a bug with the gradle spotless plugin?
like, "there's a better way to do this"
e
not really, not if they want to be configurable in the build script
c
I don't have this problem with
errorProne
which has the option to do a similar thing
but also allows me to do it in
dependencies { }
I suppose I could request that feature... although I'm not sure how it works
(this is what I get for wanting my gradle kotlin files formatted too
a
try adding this to every settings.gradle.kts (including the one in buildSrc/build-logic)
Copy code
pluginManagement {
  repositories {
    mavenCentral()
    gradlePluginPortal()
  }
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)

  repositories {
    mavenCentral()
    gradlePluginPortal() // this should only be necessary in buildSrc/settings.gradle.kts
  }
}
The strict repositoriesMode should trigger an error for any plugins that are adding repositories. These can be hard to track down, but at least you'll be able to see what plugins are causing issues.
👍 1