I’ve been tasked with converting an Ant build to Maven. I’m not experienced with maven at all. I have for the most part been able to create the jar file “cem_rvtool.jar” that Ant was building, however, there are some missing dependencies in the jar file when I inspect it with a diff tool, Beyond Compare.
My project directory looks something like this:
project
- src
- target
- jar files
I need those jar files to be packaged into the final jar, placed at the root directory. I’ve been doing a lot of research but haven’t found a way to get this to work. Here is the pom file that I’m working with at the moment.
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader</mainClass>
</manifest>
<manifestEntries>
<Build-Version-ID>${cem.build.version.id}</Build-Version-ID>
<Build-Timestamp>${timestamp}</Build-Timestamp>
<Rsrc-Main-Class>gov.cms.ccem.releasetool.RVToolLauncher</Rsrc-Main-Class>
<Rsrc-Class-Path>./ jakarta-oro-2.0.8.jar ${jarfile.commons.beanutils} ${jarfile.commons.logging} ${jarfile.commons.lang} ${jarfile.commons.text} ${jarfile.slf4j.api} ${jarfile.log4j.api} ${jarfile.log4j.core} ${jarfile.log4j.slf4j.impl}</Rsrc-Class-Path>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<copy file="target/cem_rvtool.jar" tofile="../../deploy/cem_rvtool.jar"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>project.properties</file>
<file>cem.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<includes>
<include>gov/cms/ccem/releasetool/*</include>
<include>resources/*</include>
<include>../*</include> <!-- Trying to capture jars -->
<include>../*.jar</include> <!-- Trying to capture jars -->
</includes>
<excludes>
<exclude>javax</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
Coincidentally, the jar files that I need to include are the dependencies listed above the plugins section (not shown). Any help would be appreciated. Thank you.