I'm ashamed to say that I've never really got to g...
# community-support
r
I'm ashamed to say that I've never really got to grips with included builds. I asked ChatGPT for a way to be able to include / uninclude a build globally without risking committing something accidentally, and it came up with this:
settings.gradle.kts
Copy code
if (file("settings-include.gradle.kts").exists()) {
  apply(from = "settings-include.gradle.kts", optional = true)
}
.gitignore
Copy code
settings-include.gradle.kts
settings-include.gradle.kts
Copy code
includeBuild("../other-project")
Then you can just comment that line in
settings-include.gradle.kts
in and out. Is this how everyone else is doing it?
m
I commit it accidentally 50% of the times šŸ˜…
The good thing is that CI catches it very quickly
r
That's why I `.gitignore`'d it
m
I just edit my
settings.gradle.kts
file because I want to see it in
git status
and I don't mind committing it accidentally because my CI will catch it quickly
But if you don't want that your solution should work well
I'm actually a lot more anxious about committing debug
println
because those will get through CI undetected but included builds will fail every time so I don't mind that much 🤷
v
I doubt that "this is how everyone else is doing it". I've never seen such construct actually. An I would also never use it, for example because it uses a legacy script plugin which is highly discouraged and has quite some quirks. Maybe no quirks for this one-liner, but still I'd not use them. Like Martin I just edit my settings script, just that I never accidentally checked it in because I usually look over the changes again I'm going to commit and latest by then always caught it so far, but usually I anyway use
git add -p
and add hunk by hunk that I want to commit unless I do really big changes. It also depends on what you do the composite build for. If it is just to have both projects in the same IDE and connected, you could also just define the composite build in the IDE. If it is only for necessary for a Gradle run, you can define the composite build via commandline argument.
āž• 1
šŸ™ 1
What you could maybe do is: • use an init script • there checks for the existence of files named like "include-projects" • if found, read it, iterate it, include the projects • add "include-projects" to your global gitignore This way you don't have to change anything in the project, not even the gitignore, it will just work for all projects ootb on your box, it does not use legacy script plugins.
I did not try whether it works, but I'd expect it to. Actually now that I wrote this down, I might start to like the idea and try it. šŸ˜„
m
I dread init scripts because I always forget to check them when something goes wrong
v
While drawback is, that then
git status
will not show that I currently use the dependency included instead of binary. šŸ˜•
m
I guess it's a good case of "whatever floats your boat"
šŸ‘ 1
e
I wrote https://github.com/ephemient/git-magic/blob/main/git-filter-local which uses git smudge/clean filters to invisibly maintain local diffs on top of projects
šŸ™ 1
e
I've had a similar idea to @Vampire that I never actually tried which is to have a gitignored directory, and to symlink any included builds that I want, and in
settings.gradle.kts
I iterate those and add them as
includedBuild
r
I never replied and thanked you all - apologies. I finally got around to applying Vampire's solution via this script. To build against a local build:
Copy code
shell
./include-build.sh <relative_path_to_build>
To stop building against all local builds:
Copy code
shell
./include-build.sh -r
To stop building against specific local builds:
Copy code
shell
./include-build.sh -r <relative_path_to_build>
šŸ‘Œ 1