Is it possible to set a project level gradle prope...
# random
d
Is it possible to set a project level gradle property or an environment variable in IntellIJ?
a
sounds like a job for a
Copy code
local.properties
file. No?
d
Doesn't work. I'd have to parse it myself and I'm looking for something built in.
a
Yes, you can use a
gradle.properties
file Ex:
Copy code
kotlin.code.style=official
org.gradle.parallel=true

logbackVersion=1.2.11
awsVersion=0.15.1-beta
ktorVersion=1.6.8
kotlinxSerializationVersion=1.3.1
koinVersion=3.1.4
korimVersion=2.2.2
Then reference the versions in a build.gradle.kts file
Copy code
val logbackVersion: String by project
val awsVersion: String by project
val ktorVersion: String by project
val kotlinxSerializationVersion: String by project
val koinVersion: String by project

dependencies {
    implementation(project(":core:core-maths"))
        implementation("ch.qos.logback:logback-classic:$logbackVersion")
...
}
         You can also use
by rootProject
instead if you have a nested module and want to get the value from a root gradle property file instead of the immediate parent.
d
Sorry I should've clarified. I don't want to commit the variable to git.
It's variable is a path to a local dynamic library. Everyone's is gonna be different depending on their OS and distro.
a
Oh, then you can try with env variables maybe?
Copy code
val myVar: String = System.getenv("varname")
d
Yes but how do I set the env variable in IntelliJ?
a
@Dominaezzz Maybe try editing the run configuration?
Otherwise use terminal,
export MY_VAR=var_value
d
The former is ignored by gradle sync
The latter is a bother to do on Linux but it seems like the only way.