In the pom.xml there is a usage of maven-dependency-plugin
to download a specific external JAR file to a separate location (in /tmp/externalTestJars/testjar.jar).
And I want to use exec-maven-plugin
to run a java class in the testjar.jar file (Main.java).
I found this SO question asking kinda same question but the answer for that question did not help me.
If I directly run the Main.java file (in the original project where the .jar got created, using mvn exec:java
) I can use the below pom configuration.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<mainClass>org.example.Main</mainClass>
<!-- need to pass two arguments to the Main.java file main method -->
<arguments>
<argument>arg one</argument>
<argument>arg two</argument>
</arguments>
</configuration>
</plugin>
In the above SO question it has an answer like 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 those arguments will be considered as the one to pass for the main method in Main.java sine it is expecting two arguments. So that approach didn't work for me.
Can this be done using exec maven plugin or is there any other method to do the same.