1

I am working on a JSF taglib. To test it I compile it to a JAR as described here and add it manually to a Dynamic Web Project (In the WEB-INF/lib directory).

I know that this step can be automated, but I do not know how. Can anybody explain how to copy a generated jar to a second project in Eclipse?

Thanks in advance!

padmalcom
  • 1,156
  • 3
  • 16
  • 30

1 Answers1

1

quite some steps to do :)

  • add a pom.xml into your project and follow the maven directory structure. use packaging "jar" for the taglib project. Lets assume you use groupId=com.company.taglib artifactId=company-taglib version=1.0.0-SNAPSHOT
  • if you do a mvn install on this project it will copy the jar into your local maven repository (usually found at ~/.m2/ - now maven can resolve the dependency on your local machine
  • add a pom.xml to your webproject, use packaging "war" and add the taglib project as a dependency (within <dependencies> in pom.xml).
<dependency>
  <groupId>com.company.taglib</groupId>
  <artifactId>company-taglib</artifactId>
  <version>1.0.0-SNAPSHOT</version>
</dependency>

Maven will resolve this dependency from your local repository. In Eclipse using the m2e Plugin it will resolve the project directly.

To "publish" the taglib.jar you need an infrastructure to share artifacts. Usually using a repository proxy (Sonatype Nexus or Artifactory). You can also use a network folder using the file:// protocol for quick startup.

In the pom.xml you need to add the <distributionManagement> section (in the taglib pom.xml) to specify the folder / proxy the artifacts are uploaded to. A mvn deploy will then build and copy the jar file for you.

Other developers need to add that location as repository in settings.xml (I dont recommend doing that in pom.xml) or if you setup a maven proxy configure a mirrorOf in settings.xml

There are archteypes available (project templates) that will help you creating initial project structures: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

see also: http://maven.apache.org/guides/getting-started/index.html

wemu
  • 7,952
  • 4
  • 30
  • 59
  • Thank you for the detailed explanation! The hint to the repository proxy / the network folder was very valuable! – padmalcom Mar 18 '13 at 12:29