I have an old project in RAD 7.5 that is built as a JAR to be used as a library in other projects. I’m trying to convert it to be built with Maven (part of a larger effort to move most projects to Maven) and I’m stuck on the classpath. The pom.xml looks liket his:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>My Framework Jar</name>
<groupId>com.mycompany</groupId>
<artifactId>MyFramework</artifactId>
<version>1.0.1</version>
<packaging>jar</packaging>
<build>
<!-- can't change the directory structure to how Maven likes it so specify the source directory -->
<sourceDirectory>src/com/mycompany</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!-- This will add project version into manifest file-->
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<finalName>MyFramework</finalName>
</build>
</project>
The problem is that when I try to produce a jar, I get tonnes of “cannot find symbol” errors that reference class names in the jar files that this project is dependent on. There’s already a .classpath file that seems to be what RAD uses for building the project – is there a way to get Maven to read this file so it knows what jars are needed?
Since Maven manages the dependencies in the repository on your machine and uses them to compile and run your project those libraries are no longer directly in your project. So you might have to change your .classpath to point to your repo (~/.m2). When I use Maven Eclipse has a nice plugin that allows you to convert the project to a Maven project. This plugin allows the classpaths to be managed in the pom.