mrbray99
(Mike B)
September 10, 2023, 12:29pm
1
I am trying to parameterise my builds to enable other users easily adapt the build to their work.
I have
dependencies {
compileOnly(fileTree("c:/Program Files/Moneydance3069/lib")
which works fine. I want to add a property to gradle.properties, i.e:
gradle.properties
moneydanceLib = "c:/Program Files/Moneydance3069/lib"
and in the build.gradle.kts I put
build.gradle.kts
dependencies {
val moneydanceDir: String = rootProject.findProperty("moneydanceLib") as String
compileOnly(fileTree("$moneydanceDir"))
It uses a path of C:\Users\xxxxx.gradle\daemon\8.3"c:\Program Files\Moneydance3069\lib" which of course doesnot work.
Does anyone know how to specify an absolute path? Through experiment a String literal works but a String variable with the same information doesn’t
Vampire
(Björn Kautler)
September 10, 2023, 9:52pm
2
The problem is not string literal vs string variable.
The problem is, that the quotes are part of the string in the properties file.
And due to that the path is not recognized as absolute path but appended to the working directory.
mrbray99
(Mike B)
September 11, 2023, 6:53am
3
Thanks,
Taking the quotes off worked. I have also moved away from using fileTree as has been suggested to use the flatDir, i.e
gradle.properties
moneydanceLib = c:/Program Files/Moneydance3069/lib
build.gradle.kts
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
flatDir {
dirs(rootProject.findProperty("moneydanceLib"))
}
}
/*
*
* Place module specific dependencies here
*/
dependencies {
compileOnly(":moneydance")
compileOnly(":httpclient-4.5.6")
compileOnly(":httpcore-4.4.10")
compileOnly(":gson-2.5")
1 Like
Vampire
(Björn Kautler)
September 12, 2023, 2:17pm
4
Yes, flatDir
is practically always better than files
or fileTree
.