Pom.xml uses the maven-dependency-plugin
to load a specific external JAR file into a separate location (in / tmp / externalTestJars / testjar.jar).
And I want to use exec-maven-plugin
to run the java class in the testjar.jar file (Main.java).
I found this SO question by asking the same question, but the answer to this question did not help me.
If I directly run the Main.java file (in the original project where the .jar was created using mvn exec:java
), I can use the configuration below pom.
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <mainClass>org.example.Main</mainClass> <arguments> <argument>arg one</argument> <argument>arg two</argument> </arguments> </configuration> </plugin>
In the SO question above, he has an answer, as shown below, to run a java file inside a .jar file.
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <mainClass>org.example.Main</mainClass> <arguments> <argument>-jar</argument> <argument>/tmp/externalTestJars/testjar.jar</argument> </arguments> </configuration> </plugin>
But in my case, these arguments will be considered as passed for the main method in the power of Main.java, it expects two arguments. So this approach did not work for me.
Is it possible to do this with an exec maven plugin or is there any other way to do the same.
source share