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

Gradle centralised repo management causes problems #628

Open
keynmol opened this issue Aug 2, 2023 · 6 comments
Open

Gradle centralised repo management causes problems #628

keynmol opened this issue Aug 2, 2023 · 6 comments

Comments

@keynmol
Copy link
Contributor

keynmol commented Aug 2, 2023

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

@samiabuzeineh-wk
Copy link

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

@dmmedakin
Copy link

workaround:

.settings.gradle.kts

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
       // ...
    }
}

@samiabuzeineh-wk
Copy link

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?

@keynmol
Copy link
Contributor Author

keynmol commented Oct 10, 2023

@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 :)

@samiabuzeineh-wk
Copy link

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!

@keynmol
Copy link
Contributor Author

keynmol commented Oct 11, 2023

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.

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

No branches or pull requests

4 participants