How can I create a class path dependency that uses an environment variable?

I have a project that depends on a set of .jars that users have locally installed, but are not under source code control. These jars are installed in different places on different machines (mainly due to platform differences) and I'd like to put them the project classpath without hardcoding the location.

The usual solution to this kind of problem is to use an environment variable that each user can set to point at their local copy of the jars. This works great for our ant build scripts and apparently there's a way to do this in Eclipse too. I've been looking for a similar feature in IntelliJ IDEA and haven't found it yet.

I've been looking at the Project Structure/Modules/Dependencies view so maybe I'm just looking in the wrong place.

Thanks.

3 comments
Comment actions Permalink

Hello Phil,

You can't use environment variables in dependency paths but you can define
a path variable pointing to the location of the .jars. Then every user will
get prompted to specify the value for the path variable when opening the
project.

See Settings | Path Variables, and check out the Help file for more information.

I have a project that depends on a set of .jars that users have
locally installed, but are not under source code control. These jars
are installed in different places on different machines (mainly due to
platform differences) and I'd like to put them the project classpath
without hardcoding the location.

The usual solution to this kind of problem is to use an environment
variable that each user can set to point at their local copy of the
jars. This works great for our ant build scripts and apparently
there's a way to do this in Eclipse too. I've been looking for a
similar feature in IntelliJ IDEA and haven't found it yet.

I've been looking at the Project Structure/Modules/Dependencies view
so maybe I'm just looking in the wrong place.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks, that's just what I was looking for. I created a path variable, added the jar as a project dependency, and the project file uses the path variable instead of a full path name.

I didn't think it was working at first, as I didn't see any way to use my path variable when adding a dependency, and the path variable wasn't shown in the module dependency UI -- the full path was shown instead. This seems like a bug to me.

0
Comment actions Permalink

Hello Phil,

Path variables are only used when saving, they are not displayed in the UI.
This behavior might be confusing but currently that's by design.

Thanks, that's just what I was looking for. I created a path variable,
added the jar as a project dependency, and the project file uses the
path variable instead of a full path name.

I didn't think it was working at first, as I didn't see any way to use
my path variable when adding a dependency, and the path variable
wasn't shown in the module dependency UI -- the full path was shown
instead. This seems like a bug to me.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.