実行コンフィギュレーションVM引数でeclipseクラスパス変数M2_REPOの値にアクセスする

In the run configuration of eclipse, you are provided with a set of default variables that you can use in the VM arguments, like container_path and env_var.
What I want to access is a classpath variable, M2_REPO, but can't see a way of doing this. I need to specify a javaagent in the VM arguments, which requires a path to a jar file. This jar file lives in the maven repository, but I can't find a way of specifying the path to the maven repository using the already configured M2_REPO Classpath variable (configured in windows->preferences->java->Build Path->Classpath variable).
What I would like to do is use this as my VM arguments but can't because classpath_var isn't a real variable.

-javaagent:${classpath_var:M2_REPO}/org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar

VM引数で M2_REPO の値にアクセスする他の方法はありますか?

6
他の人が私のように質問を誤読する場合に備えて、 $ {env_var:VAR_NAME} を使用することができます。 -javaagent:$ {env_var:M2_HOME}/repository/org/apache/openjpa /‌ openjpa/2.1.0これは私のリポジトリが%M2_HOME%/openjp‌ a-2.1.0.jar
追加された 著者 xverges,

1 答え

This isn't exactly what you asked for, but it worked for us as a way of sharing a codebase and not having hard coded paths in our run configurations. Rather than using a classpath variable, use a string substitution variable (configured in windows -> preferences -> run/debug -> String Substitution). Set it to the same path as the value of M2_REPO and save. Using the above example if your string substitution variable name was also M2_REPO, the VM Argument would be

-javaagent:${M2_REPO}/org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar

さらに明確にするために、openjpa_2_1_0_agent文字列置換変数を作成してオープンjpa jarファイルに直接書きます。

4
追加された