How to use variables for classpath definition in Eclipse launch configurations?

試著忘記壹切 提交于 2019-11-30 09:03:37

Edit your launch configuration. Go to the "classpath" tab. Focus on "User Entries". Click the "Advanced" button.

  • To add an entry based on a classpath variable, select Add classpath variable and click OK. A dialog will open. Focus on M2_REPO and click the "Extend" button. Select your JAR file.
  • To add an entry based on a system environment variable, select Add variable string, and in the editbox below, type: ${env_var:your-environment-variable-name}/path-to-jar. For example, if your system environment variable is MYVAR and the JAR file is under subdir/myfile.jar, you should type ${env_var:MYVAR}/subdir/myfile.jar.

You could load that value from maven properties.

Maven stores repository path in maven.repo.local property.

Place ${maven.repo.local} into your configuration file.

<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
    ...
    <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;runtimeClasspathEntry externalArchive=&quot;${${maven.repo.local}}/com/google/gwt/gwt-dev/2.0.3/gwt-dev-2.0.3.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;"/>
    ...
</listAttribute>

Then setup filtering in pom.xml for your configuration file so ${maven.repo.local} will be replaced with property value.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!