Slackbot
07/10/2023, 6:09 PMephemient
07/10/2023, 6:24 PM:something
project is the parent of :something:else
.
if you don't want that then you need to flatten the project hierarchy. you can do that without changing directory layout,
include(":something-else")
project(":something-else").projectDir = file("something/else")
Miles Peele
07/10/2023, 7:03 PMChris Lee
07/10/2023, 7:05 PMMiles Peele
07/10/2023, 7:10 PMMiles Peele
07/10/2023, 7:17 PMSettings
to wrap this logic, but where does the file(...)
method come from? Is that just <http://java.io|java.io>.File($PATH)
?Chris Lee
07/10/2023, 7:18 PMMiles Peele
07/10/2023, 7:19 PMSettings
object doesn't seem to have a file(..)
method defined?
https://docs.gradle.org/current/javadoc/org/gradle/api/initialization/Settings.htmlChris Lee
07/10/2023, 7:20 PMFile
if need be.ephemient
07/10/2023, 7:22 PMMiles Peele
07/10/2023, 7:23 PM.kt
file of an included build:
fun Settings.includeProject...
And that object doesn't have a file
defined. I would rather not copy+paste the projectDir...
thing everywhere, trying to figure out a way to standardizeMiles Peele
07/10/2023, 7:24 PMScript
insteadephemient
07/10/2023, 7:25 PMFile
directly fails on some platforms while file
works (we've hit this in our own build, never determined why) https://github.com/gradle/gradle/issues/19249Vampire
07/10/2023, 10:35 PMFile(...)
with a relative path is relative to the current working directory. The current working directory often is the project directory, but not always and also in no way guaranteed. So whenever you use File(...)
with a relative path, your build is broken at least as time bomb. Using File(...)
with a relative path is almost always wrong in any program unless the relative path comes from the user via command line option. file(...)
on the other hand resolves the path relative to the project or settings directory.ephemient
07/10/2023, 10:51 PMFile("$projectDir/...")
, it's not just the working directory, it was some weird classloader stuffephemient
07/10/2023, 10:52 PMfile()
is better anywayVampire
07/10/2023, 10:54 PMephemient
07/10/2023, 10:55 PMephemient
07/10/2023, 10:55 PMSettings
or any other specific receiver
// settings.gradle.kts
fun includeFlattened(projectDir: String) {
val projectName = projectDir.replace('/', '-')
include(projectName)
project(projectName).projectDir = file(projectDir)
}
includeFlattened("something/else") // etc.
ephemient
07/10/2023, 10:57 PMMiles Peele
07/11/2023, 12:47 AMsettings.gradle.kts
files - wanted to define this method in one place and use it everywhereVampire
07/11/2023, 2:22 PMbuildscript { ... }
block if not a plugin. Then you can use it.