Is it possible to substitute a version catalog cre...
# dependency-management
l
Is it possible to substitute a version catalog created from GAV coordinates using an included build? (More in ๐Ÿงต)
I have a settings plugin that is creating a version catalog:
Copy code
DependencyResolutionManagement dependencyResolutionManagement = target.getDependencyResolutionManagement();
MutableVersionCatalogContainer versionCatalogs = dependencyResolutionManagement.getVersionCatalogs();

versionCatalogs.register(VERSION_CATALOG_NAME, versionCatalogBuilder -> {
    versionCatalogBuilder.from(VERSION_CATALOG_COORDINATES);
});
From what I can tell, the catalog can only be resolved if I'm also using
dependencyResolutionManagement
for central repository declaration.
I think this effectively prevents me from substituting the dependency, right? (Because the declarations in
pluginManagement
don't apply.)
j
You can use a normal
includeBuild
(outside pluginManagement) for the build that creates/exports the catalog. What is not working is that the catalog is produced by a task, because it is needed at configuration time (and it is not a plugin, but a normal dependency). So the catalog would need to be defined directly as a TOML file in the project "producing" it. At least I don't know of another solution. See: https://github.com/gradle/gradle/issues/19288#issuecomment-1399277313
l
I see. Thank you for the pointer. I think my issue is that I'm trying to publish the catalog from the same project that is also publishing the Gradle plugin which causes dependency metadata to be written incorrectly. I'll move it to two separate subprojects and see if that fixes it.
Hmm. Still can't get this to work right now. Well, it's not urgent. I'll investigate more to figure out if I'm doing something wrong and file an issue otherwise. ๐Ÿ™‚
๐Ÿ‘ 1