Set XP_HOME variable in build.gradle file?

Hey,

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.

//runar

Hi.

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.

/srs

4 Likes

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.

2 Likes

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…

2 Likes

Done. http://xp.readthedocs.org/en/latest/developer/apps/basics/building.html

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.

3 Likes

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. http://labs.enonic.com/articles/working-with-multiple-xp-projects

2 Likes

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.