0

I have multiple kotlin gradle projects on multiple machines. I have a good system to keep their modules in sync with git submodule. I now want my build.gradle.kts and settings.gradle.kts to stay in sync between projects as well. According to this question my options seem to be to either put these files inside another folder that is a git submodule, or use git subtree. I am considering git subtree to not be worth it because it took me a long time to thoroughly develop a good workflow with git submodules and I don't want to add a whole new layer of complexity on top of that. So my only option seems to be to put these files inside another folder that is a git submodule. Linking files is not good enough since I have multiple machines, and modularizing my gradle code into a plugin is turning out to be crazy hard because both script plugins as well as plugins or functions defined in buildSrc/src/main/kotlin seem to never be able to do all the things that can be done in a regular buildscrips. For example, this throws a compiler error in buildSrc/src/main/kotlin/file.kt but not in build.gradle.kts :

fun Project.rootBuild() {
  subprojects {
    tasks {
    }
  }
}

I know its a strange and open-ended question, but one concrete part of my question is whether or nto its possible to just move my buildscript and setting file into a folder and somehow tell graldle that's where they are. The more open ended part of the question is if there is any other way to sync my buildscript and settings files or if theres something that would make git subtree simpler, or something that would help me understand how to move my buildscript code into a plugin (which can be a submodule) without having so many compiler errors.

Matt Groth
  • 328
  • 3
  • 16
  • It depends on your set up. Probably the best solution is to use a [multi-project build](https://docs.gradle.org/current/userguide/multi_project_builds.html#multi_project_builds), where all projects are in one repository and you use buildSrc plugins to share common configuration. If you really want to share configuration scripts between very separate projects, you can create a [custom Gradle distribution](https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:custom_gradle_distribution) – aSemy Feb 22 '22 at 16:04

0 Answers0