Set vm default arguments via maven for eclipse

I want to specify vm args -Djava.library.path =. / Src / main / resources so that the DLL is automatically taken, and I want to specify this in maven, so other developers do not need to manually configure eclipse.

I thought it might be that the maven eclipse plugin might help, so I could do something like

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.7</version> <configuration> DO MAGIC HERE ???? <<----- </configuration> </plugin> 

But I see no way to add VM args from inside the plugin.

I fixed this to run my tests through maven on the command line

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.3</version> <configuration> <argLine>-Xmx768m -Xms128m -Djava.library.path=${basedir}/src/main/resources/</argLine> </configuration> </plugin> 

My current solution is that I will have to tell the developers to add this manually in eclipse, which does not look very good.

Does anyone have any ideas on how to solve this.

amuses

David.

+8
eclipse maven jvm-arguments maven-eclipse-plugin
source share
2 answers

Perhaps this should be a more general question:

Is there a way to add a DLL to a virtual machine without specifying it through the library path?

I read somewhere that placing the DLL in the root of the application and specifying the DLL in MANIFEST.MF with its hash code starts the virtual machine to automatically pick it up. This may be completely wrong.

+1
source share

My interpretation of your problem is that your application loads the DLL, and that DLL is in your project in the resources folder. Correctly?

You can get the full path to the DLL if the DLL is inside a folder in the class path and loads it using:

 // assuming dll is located in the default package URI dllUri = this.getClass().getResource("/mydll.dll").toURI(); File dllFile = new File(dllUri); System.load(dllFile.getCanonicalPath()); 

It does not depend on maven. There are only two problems:

  • The solution is system independent, since you specify the file suffix in the getResource () parameter
  • This will not work if the DLL is inside the JAR. In this case, we create a JAR extractor that will extract the DLL into a temporary folder and call System.load () with the file in the temp folder.
+1
source share

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


All Articles