My hope was that it would be easy to get Maven to run our application on any machine by simply deploying the pom.xml and using the maven exec
goal.
The main class to run is inside the jar which is produced from the same pom.xml. But it seems that, while Maven quite nicely includes all the dependencies on the classpath, the pom's jar does not get included, or else it cannot be resolved from the repository where maven deployed it (which is an internal not public repository).
The steps I followed:
- run
mvn deploy
-- this deploys our jar on an internal maven repository - install maven on the target machine (not the same as the build machine)
- deploy the pom.xml to the target machine.
- try to run using
mvn exec:java ...
ormvn exec:exec ...
What I see is that Maven pulls all the dependency jars onto the classpath correctly, but does not pull in the jar described by the pom.xml.
I tried various configuration options in the pom.xml, but nothing seemed to work. First, tried to configure exec:java
as shown in this answer, but Maven did not search the internal repository for that jar. (It did seem to check the public maven repositories though).
Second, I tried to switch to the exec:exec
version and configure like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>com.ezxinc.tfix.TFix</argument>
</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>ezxinc</groupId>
<artifactId>tfix</artifactId>
<version>0.0.3-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
The dependency
shown there is the information for the jar which the pom.xml deployed into our internal repository.
Of course, everything works fine if I unjar the class files into target subdirectory beneath the one where the pom.xml is.
If it helps, the full pom.xml can viewed here.