Search code examples
maven-2jarclasspath

Maven: add a folder or jar file into current classpath


I am using maven-compile plugin to compile classes. Now I would like to add one jar file into the current classpath. That file stays in another location (let's say c:/jars/abc.jar . I prefer to leave this file here). How can I do that?

If I use classpath in the argument:

<configuration>
 <compilerArguments>
  <classpath>c:/jars/abc.jar</classpath>
 </compilerArguments>
</configuration>

it will not work because it will override the current classpath (that includes all the dependencies)


Solution

  • This might have been asked before. See Can I add jars to maven 2 build classpath without installing them?

    In a nutshell: include your jar as dependency with system scope. This requires specifying the absolute path to the jar.

    See also http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html