How do I create a string substitution variable for maven in Eclipse?
Author: Deron Eriksson
Description: This tutorial describes how to create a string substitution variable in Eclipse for maven.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


It can be useful to create an EclipseSW string substitution variable for mavenSW if you execute maven as an external tool in Eclipse. If you upgrade your version of maven, you would only need to update the string substitution variable once to take care of all references to maven in your external tool configurations rather than needing to update all of the configurations one at a time.

To create an Eclipse string substitution variable, go to Window → Preferences and Run/Debug → String Substitution. Click the New button.

String Substitution

I named my variable "maven_exec", as described in http://maven.apache.org/guides/mini/guide-ide-eclipse.html. I set its value to be the path to my mvn.bat file. I gave the variable a description. I clicked OK and the OK. The "maven_exec" variable is saved.

Creating 'maven_exec' String Substitution Variable

I had previously created a "mvn clean" external tool configuration with the maven path hardcoded. I deleted this Location and clicked the Variables button.

External Tool Configuration

I selected the "maven_exec" variable.

Selecting 'maven_exec' variable

The "maven_exec" variable is now being used for my Location value.

'maven_exec' variable in Location of External Tool Configuration

That's all there is to it!