0

I can see many cook books how to set things in root project and propagate them to children, but I cannot find ways how to do it in opposite way in gradle 8+.

I have like 15 modules producing versioned artifacts. I'm building about 5 applications using those modules. They all should use same java sourceCompatibility and targetCompatibility version, they are in same group, have same compile options, use same useJUnitPlatform, they use same custom functions, and have same dependency versions and plugin versions.

It's team work, so all this things are versioned in git. I can use java-platform for dependency management.

There application now have lots of identical code in build.gradle.kts and settings.gradle.kts making it increasingly difficult to maintain. Also we have more applications coming.

So I want to create single module from which all these things should inherited. I want to use it as project dependency, to make it easy when developing localy and versioned artifact dependency to build production artifacts.

It must be possible to build each module separately (they are used by multiple root projets).

It seems like gradle is not supposed to be used this way. Or I miss something. So please can anybody guide me how to avoid repeating same code snippets in gradle build files?

Pavel Niedoba
  • 1,554
  • 2
  • 19
  • 36
  • You can de-duplicate Gradle configuration by using convention plugins. Here are some links with more info: https://docs.gradle.org/8.2/userguide/organizing_gradle_projects.html#sec:build_sources https://docs.gradle.org/8.2/samples/sample_sharing_convention_plugins_with_build_logic.html https://stackoverflow.com/a/71892685/4161471 – aSemy Jul 05 '23 at 16:27
  • OMG, why is it so complicated? – Pavel Niedoba Jul 08 '23 at 17:40
  • Tell me about it! Gradle is not an easy tool to love. Is the project you're working on open source? If is, then share a link and maybe I can help out with some PRs. – aSemy Jul 08 '23 at 18:41

0 Answers0