PaperMC / paperweight

Gradle build system plugin for Paper and Paper forks
269 stars 52 forks source link

userdev is not fully compatible with central repository declaration #288

Open radstevee opened 1 month ago

radstevee commented 1 month ago

When applying userdev to a project with a dependencyResolutionManagement { repositories { ... } } block, these will be discarded and only maven central and the paper repo will be added. MRE: https://github.com/radstevee/paperweight-288-mre

pw-mre:main: Could not find net.radstevee.packed:packed-core:1.0.3.
Searched in the following locations:
  - https://repo.maven.apache.org/maven2/net/radstevee/packed/packed-core/1.0.3/packed-core-1.0.3.pom
  - https://repo.papermc.io/repository/maven-public/net/radstevee/packed/packed-core/1.0.3/packed-core-1.0.3.pom
Required by:
    root project :

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
jpenilla commented 1 month ago

userdev adds repos to Projects to implement it's functionality. So this is expected behavior with the default repositories mode and central declaration: https://docs.gradle.org/current/userguide/centralizing_repositories.html#sec:repositories-mode.

In the future I'd like to implement a settings plugin that can add the repos centrally for compatibility with PREFER_SETTINGS and FAIL_ON_PROJECT_REPOS, and better flexibility with PREFER_PROJECT. But this would require a non-trivial rework.

The current technique to work with PREFER_PROJECT would be creating a custom plugin (with an included build or buildSrc) that adds your repos and is applicable to Settings or Project instances. Then you would apply the plugin in settings and your userdev projects. You would probably also want to disable injecting the Paper repo on the paperweight extension if you declare Paper in your central repo list.

This way projects without repos defined will use the settings repos, and userdev projects will use the project repos, which will now contain the common/central repos in addition to the userdev ones.