views:

111

answers:

1

Hi I am using maven-compile plugin to compile classes. Now i would like to add one jar file into current classpath. that file stays in another location (let says 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 working because it will override the current classpath (that include all the dependencies)

Please help me.

+1  A: 

This might have been asked before. See http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them#364188

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

michid
I wonder when people will stop suggesting abusing the `system` scope See Brian's [answer](http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them/764684#764684) in the question you linked to. See also [this previous answer](http://stackoverflow.com/questions/3280834/local-jars-are-not-included-in-class-path/3281409#3281409).
Pascal Thivent
Thanks. it worked :-)
David
one more question. If i need to add a folder (contains many .class file) into classpath. how can i do it.
David