Reputation: 1449
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!
Upvotes: 1
Views: 1206
Reputation: 8160
quite some steps to do :)
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<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
Upvotes: 1