Variables for VM args

Hi all,

I'm rather new to IDEA and I'm trying to move over from Eclipse. In Eclipse I use built in variables as JVM args when I run jUnit test cases and I'm looking for a way to do something similar in IDEA but I haven't found anything (maybe I'm just searching with the wrong keywords).

Here's my rationale. I work on Apache OpenJPA and one of the ways to specify the database to use is to pass in a set of JVM args like this :

-Dopenjpa.ConnectionURL=jdbc:derby:/target/temp-db;create=true
-Dopenjpa.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver
-Dopenjpa.ConnectionUsername=app
-Dopenjpa.ConnectionPassword=none

In Eclipse I built up a set of these variables for Derby, DB2, Oracle etc. and set the appropriate variable when I run a jUnit test. The benefit is that I can switch the database quickly without rebuilding my application (the alternative would be to put this information in an xml file).

Is there a way to do this in IDEA that I just haven't been able to find?

Thanks in advance,

-mike

1 comment
Comment actions Permalink

I don't know how exactly those "variables" work in Eclipse.
You could duplicate the JUnit run configurations and configure each with a different set of VM params.
That's of course a bad solution if you frequently run different (sets of) tests (which will create a new run configuration).

Some generic solution to this would be very welcome. Something like ant filter tokens would be nice:
- Define and manager sets of key/value pairs in IDEA
- quickly activate/deactivate any of these
- have IDEA replace keys with corresponding values everywhere (source files, descriptor files, run configurations, ...)

Some time ago I tried to start writing a plugin for that, but the mechanics of
that are intricate and not supported by the open api.

What I usually do is (as you suggest) have the info in separate xml files and
then use individual ant targets (set-db-derby, set-db-db2, ...) that copy the
specific xml file to a place where IDEA's compilation process picks it up
(e.g. a configured resource descriptor).

Michael Dick wrote:

Hi all,

I'm rather new to IDEA and I'm trying to move over from Eclipse. In Eclipse I use built in variables as JVM args when I run jUnit test cases and I'm looking for a way to do something similar in IDEA but I haven't found anything (maybe I'm just searching with the wrong keywords).

Here's my rationale. I work on Apache OpenJPA and one of the ways to specify the database to use is to pass in a set of JVM args like this :

-Dopenjpa.ConnectionURL=jdbc:derby:/target/temp-db;create=true
-Dopenjpa.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver
-Dopenjpa.ConnectionUsername=app
-Dopenjpa.ConnectionPassword=none

In Eclipse I built up a set of these variables for Derby, DB2, Oracle etc. and set the appropriate variable when I run a jUnit test. The benefit is that I can switch the database quickly without rebuilding my application (the alternative would be to put this information in an xml file).

Is there a way to do this in IDEA that I just haven't been able to find?

Thanks in advance,

-mike

---
Original message URL: http://www.jetbrains.net/devnet/message/5241483#5241483

0

Please sign in to leave a comment.