tags:

views:

1544

answers:

2

Hi

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.

A: 

You can install the jar to your local repository using the install plugin's install-file goal, you can then declare a dependency on the artifact as normal, and it will be packaged into your war by the war plugin automatically.

If you have a remote repository, you can use the deploy plugin's deploy-file goal to deploy the jar to that repository, then your teammates can access the jar as well.

For information, there is a Jira to make this artifact available on central.


Update based on your comment. I'd recommend against doing this as it is not a good practice, but if you must host the jar in your project's source structure you can put it under say src/main/lib and use the antrun plugin to copy it to WEB-INF/lib.

For example:

  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <phase>process-resources</phase>
        <configuration>
          <tasks>
            <copy todir="${project.build.directory}/WEB-INF/lib">
              <fileset dir="src/main/lib"/>
            </copy>
          </tasks>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
Rich Seller
My intention is not to create a local repository.I want to know is there any way using maven to copy this jar from my src or resource or any other folder to the target folder
you already have a local repository if you're using Maven, there is no need to create one. It is by default located in ~/.m2/repository
Rich Seller
@Rich, my approach is not tied to the directory structure of the box, it's even less so than your antrun suggestion. ${basedir} is defined by Mavens so it's only tied to the directory structure of the project, is that all Maven about?
ZZ Coder
Thanks this worked.But as you suggest i will look into the local repository stuff
@ZZ Coder, yes you're right I misread your post. sorry
Rich Seller
@unknown, if you find a post helpful you are able to accept or upvote it.
Rich Seller
+2  A: 

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>
ZZ Coder
How do I know what basedir is for my project?
John Mill
See my edits ................
ZZ Coder