Gradle centralised repo management causes problems
Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by plugin class 'com.sourcegraph.gradle.semanticdb.SemanticdbGradlePlugin'
Stack overflow: https://stackoverflow.com/questions/69163511/build-was-configured-to-prefer-settings-repositories-over-project-repositories-b
Gradle docs: https://docs.gradle.org/7.4.2/userguide/dependency_management.html#sub:centralized-repository-declaration
Hello. We are also experiencing an issue where placing our repository within a gradle publishing task as the gradle docs have mentioned are causing issues. Only way it works is to remove it which doesn't bode well for us. Is there any update on if this will be fixed? It's currently a blocker for us
workaround:
.settings.gradle.kts
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
// ...
}
}
Updating that in our settings.gradle file produced this error:
java.lang.NullPointerException: Cannot invoke "org.gradle.api.publish.PublishingExtension.getPublications()" because the return value of "org.gradle.api.plugins.ExtensionContainer.findByType(java.lang.Class)" is null
at com.sourcegraph.gradle.semanticdb.WriteDependencies.$anonfun$printResolvedDependencies$5(SemanticdbGradlePlugin.scala:436)
at com.sourcegraph.gradle.semanticdb.WriteDependencies.$anonfun$printResolvedDependencies$5$adapted(SemanticdbGradlePlugin.scala:421)
Does it have anything to do with the fact that this is in our settings.gradle and not in a kts file?
@samiabuzeineh-wk this exception is logged, but it doesn't fail the build: https://github.com/sourcegraph/scip-java/blob/main/semanticdb-gradle-plugin/src/main/scala/SemanticdbGradlePlugin.scala#L450-L454
We expect some projects to fail there if they don't have publishing settings.
It's a piece of tech debt to make this exception less scary as it's not the first time I see it being interpreted as an error, whereas it really isn't :)
Ah yes, I do see the indexing was successfully uploaded despite these "errors" :)
Thank you all for your help, that workaround seems to have done the trick!
All credit to @dmmedakin!
FWIW I remember making an attempt to set this value dynamically during indexing, but Gradle wouldn't let me as some state was closed.
At some point I will restore that branch to see what's up.