Maven To copy jar file from local folder

user118802 picture user118802 · Sep 9, 2009 · Viewed 13.9k times · Source

I am using seam to develop my application and running it on weblogic 10.1MP Using maven2 to build the application and did not find the jboss-seam-wls-compatible.jar file in any repository. In maven how I can copy this jar from my local folder to the target/WEB-INF/lib folder.

Answer

ZZ Coder picture ZZ Coder · Sep 9, 2009

The right way to do this in Maven is to install it into a repository (remote or local).

However, there are circumstances that local repository is less preferable. For example, you run Maven on lots of machines and you don't want manually install it.

I just use the anti-pattern of checking JARs into version control in these rare cases. I don't even bother to install it to local repository because it adds another step and makes another copy of the JAR. I just use the JAR directly like this,

            <dependency>
                    <groupId>local</groupId>
                    <artifactId>homeless-jar</artifactId>
                    <version>1.0</version>
                    <scope>system</scope>
                    <systemPath>${basedir}/lib/homeless.jar
                    </systemPath>
            </dependency>

EDIT: The ${basedir} is defined by Maven. It's the base directory of the Maven project, where your pom.xml is. My example wasn't clear. See this one,

            <dependency>
                    <groupId>any-id</groupId>
                    <artifactId>any-name</artifactId>
                    <version>1.0</version>
                    <scope>system</scope>
                    <systemPath>${basedir}/src/main/lib/homeless.jar
                    </systemPath>
            </dependency>