Set XP_HOME variable in build.gradle file?


Is it possible to set XP_HOME variable in the build.gradle file ?

Why, I’m currently having multiple projects on multiple servers this way it would be set by the script.



Yes. Actually when you do not set it in the build.gradle file it will try to locate it using XP_HOME variable. So, to set it in your build.gradle file, just follow the example below:

app {
   xpHome = file('/path/to/yor/dir')

Hope that works for you.



Cool! Can that URL be relative? Like: “…/…/xp6/home”, or even use a variable for XP installation dir? Like “[XP]/home” or similar?

Relative should work, but you can add all sorts of variables in there. For example, to use it relative to your projectDir:

xpHome = file("{$projectDir}/../../xp6/home")

Or, if you want some sort of other environment variable (MY_XP):

xpHome = file("${System.env.MY_XP}/home")

Gradle is pretty flexible to do what you want.


Wow, this should definitely be added to the documentation! :smiley:

Would make it a lot simpler to work with several instances at the same time…



That doc page could still use some work to explain all the parts of the build.gradle file.

But I don’t think this is a good way to manage your projects. If you have multiple developers working on the same project on GitHub then each might have their XP home folders in different paths.

There is a better way to set up your machine for multiple projects. I made some aliases and functions in my .bash_profile to make it easy to list my xp-homes and change the $XP_HOME variable. I was going to make a labs article explaining this. I’ll post the link here when it’s done.


Loving that page in the doc! Explains a lot of things people ask about. Nice note at the end about gradle clean, had a few incidents during XP-training where we needed to use it.

I also added the part about “gradle clean build” to the troubleshooting page.

Here is a link to my labs article that explains what I think is the best way to deal with multiple installations.


Nice article, very handy when working with multiple EXP installations, especially on 5.x and 6.x-branches that need separate home folders as well.