Leon Linhart
11/14/2024, 10:12 AMVersionCatalogsExtension is not yet available when applying a project plugin via settings plugin using Gradle#beforeProject?
I have multiple repos for microservices with exactly the same layout. I was planning to dedupe my build configuration by creating a settings plugin that does three things:
⢠Registering an external version catalog
⢠Including the usual subprojects
⢠Applying project plugins to each subprojects.
The project plugins were supposed to apply dependencies from the catalog. However, when doing this as described above, I noticed that version catalogs are not accessible at this stage. Is there a better approach this?Philip W
11/14/2024, 10:19 AMLeon Linhart
11/14/2024, 10:29 AMsettings.getDependencyResolutionManagement().getVersionCatalogs().register(...)Leon Linhart
11/14/2024, 10:30 AMgradle.beforeProject().Leon Linhart
11/14/2024, 10:31 AMPhilip W
11/14/2024, 10:31 AMPhilip W
11/14/2024, 10:32 AMVampire
11/14/2024, 10:35 AMLeon Linhart
11/14/2024, 10:37 AMafterProject is run after the build script and would be too late. It would prevent me from effectively using the build script.Leon Linhart
11/14/2024, 10:37 AMVersionCatalogsExtension is not applied from a plugin either, so I can't guard it with a withPlugin(...). šVampire
11/14/2024, 10:40 AMwithPlugin('lifecycle-base") { ... } this is the bottom-most built-in plugin and should always be applied if any built-in plugin gets applied.Leon Linhart
11/14/2024, 10:41 AMLeon Linhart
11/14/2024, 10:47 AMExtension of type 'VersionCatalogsExtension' does not exist..
project.getPluginManager().withPlugin("lifecycle-base", ignored -> {
VersionCatalogsExtension versionCatalogs = project.getExtensions().getByType(VersionCatalogsExtension.class);
System.out.println(versionCatalogs.getCatalogNames());
});Leon Linhart
11/14/2024, 10:49 AMPhilip W
11/14/2024, 10:49 AMdependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
}
versionCatalogs {
register("kobol") {
from("app.softwork.kobol:catalog:0.2.16")
}
}
}
gradle.lifecycle.beforeProject {
pluginManager.withPlugin("lifecycle-base") {
extensions.getByName("versionCatalogs")
extensions.getByName("libs")
extensions.getByName("kobol")
}
}Leon Linhart
11/14/2024, 10:50 AMbeforeProject. šPhilip W
11/14/2024, 10:51 AMbase plugin?Leon Linhart
11/14/2024, 10:52 AMThomas Broyer
11/14/2024, 11:05 AMproject.beforeEvaluate so it might just be that this action actually comes later than your beforeProject action.Leon Linhart
11/14/2024, 11:12 AMVampire
11/14/2024, 11:12 AMbeforeProject then too. š¤·āāļø
But would still be strange that within the withPlugin it would still not workVampire
11/14/2024, 11:13 AMbeforeEvaluate probably is before the build script gets evaluatedVampire
11/14/2024, 11:13 AMLeon Linhart
11/14/2024, 11:13 AMVampire
11/14/2024, 11:14 AMbeforeProject come before all beforeEvaluate, there is probably not much you can do.Leon Linhart
11/14/2024, 11:14 AMLeon Linhart
11/14/2024, 11:14 AMLeon Linhart
11/14/2024, 11:15 AM