Search code examples
jakarta-eeintellij-ideatomcat6

Using IntelliJ Path Variables, how to set system properties in Tomcat server Run Configuration?


In Eclipse you could set the -D options to include {} variables that were defined elsewhere within your IDE settings. IntelliJ would seem to provide this feature with Path Variables. However, if you follow their Help documents, you're supposed to be able to reference these variables between $dollar_characters$. Further research would seem to indicate that that only applies to the interior of your project files and the replacement is done during build time.

I'm trying to create a shared server configuration where a couple of the system properties can be swapped out by the other developers, but this one has me stumped.


Solution

  • After much digging and research into seemingly unrelated issues, I began to get a larger picture of how to accomplish this:

    1. Set your Path Variables as needed.
    2. Create your Run Configuration that you intend to share and check the Share checkbox.
    3. Put in the stubs (i.e. -Dsystem.property="variable here") in the VM options field of your configuration.
    4. Find your configuration in .idea/runConfigurations and replaces the stubs with $PATH_VARIABLE$, placing them inside of quotes if the value will include spaces.
    5. Re-open the Edit Configuration screen for your Run Configuration and note that the variable expansion has succeeded. Even better, check it in and have a colleague check it out (after setting their own Path Variables) and note that the variable expansion works with their custom values.

    Note: It may seem like you ought to be able to put those $PATH_VARIABLES$ directly into those config screens, but it only seems to work if you've edited the XML files directly.