Define extra properties in Java Plugin for other scopes than project / define methods for custom repositories


ultimately I’m trying to provide some convinience methods like jcenter or google based on my companies internal maven repository.

For the groovy DSL I found the stackoverflow answer Gradle function to define custom maven repository?, which is using extra properties to do this.

While the configuration works, we have all our convinience functions in Java written plugins, that’s why I am trying to port the solution. While I already found Set extra properties from plugin written in Java it does not cover the special scope (buildscript or project repositories).

I can use the method project.getExtensions().getByType(ExtraPropertiesExtension.class), but then all the properties are project scoped. The RepositoryHandler has no method exposing any extra properties, so what’s the way to set extra properties on these Objects?

If there are any better solutions to my original intention, they are very welcome. I already know, that the extra properties approach does not work as seemless in .gradle.kts.