Queequeg
Queequeg

Reputation: 2884

Maven JSP taglib archetype

I am creating a custom JSP tag. It's quite easy to write the Java class, as well as defining the TLD.

My problem is that I don't know how to configure Maven to build a proper JAR file. I want to use my tag in other web applications as a Maven dependency. Perhaps JAR packaging isn't the best. How can I achieve this?

Upvotes: 1

Views: 1289

Answers (1)

Kris
Kris

Reputation: 14468

Typically, running:

mvn package

Will compile your code and generate a 'proper' JAR file that can then be used by other projects.

More likely, you are wondering how this new JAR file can be added to other Maven projects by simply adding a dependency in the POM file. In order to accomplish this, you will need to place your project's JAR and POM file in a repository. This repository can be the local repository on your machine (in which case any one else will have to also install the package) or in some online repository (perhaps using a tool like Artifactory to maintain your own).

If you have access to an online repository, you use the distributionManagement part of the POM to specify it and then run:

mvn deploy

To deploy to it.

To install your project in your local repository use:

mvn install

For more, dealing specifically with custom JSP tags using Maven, see this JSP custom tag example.

Upvotes: 2

Related Questions