Access to the value of the path variable of the eclipse class M2_REPO in the launch configuration configuration parameters

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

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

Is there any other way to access the value of M2_REPO in VM arguments?

+6
source share
1 answer

This is not exactly what you requested, but it worked for us as a way to share code and not have hardcoded paths in our launch configurations. Instead of using the 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 the name of the string expansion variable was also M2_REPO, the VM argument would be

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

To be even more understandable, I would just create an openjpa_2_1_0_agent lookup variable that goes directly to your open jpa jar.

+4
source

Source: https://habr.com/ru/post/902362/


All Articles