Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle start scripts env

In gradle run task I have info about lib path:

run {
    systemProperty "java.library.path", "lib/native"
}

Is it possible to add the same variable to some gradle task that will include variable to the bin scripts, for now I have to put them manualy but I would like to automate this with gradle:

CLASSPATH=$APP_HOME/lib/***.jar:$APP_HOME/lib/***.jar: ...
>>> LD_LIBRARY_PATH=$APP_HOME/lib

1 Answers

You can use some text, such as MY_APP_HOME, to define java.library.path in JVM arguments:

applicationDefaultJvmArgs = ['-Djava.library.path=MY_APP_HOMElib/native']

And then substitute it by start scripts APP_HOME variable in each script:

startScripts {
    doLast {
        unixScript.text = unixScript.text.replace('MY_APP_HOME', '\$APP_HOME/')
        windowsScript.text = windowsScript.text.replace('MY_APP_HOME', '%APP_HOME%\\')
    }
}
like image 128
Eduardo Avatar answered Aug 05 '26 17:08

Eduardo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!