I need to have a JAR dependency in the Maven generated WAR's WEB-INF/lib
folder as x-1.0.final.jar
instead of x-1.0.jar
, which is the name it has in the repository. What would be the best way to achieve this?
In my POM I have:
<dependency>
<groupId>foo</groupId>
<artifactId>x</artifactId>
<version>1.0</version>
</dependency>
I want this to appear in the WEB-INF/lib
folder as x-1.0.final.jar
.
It's and external dependency on Maven Central I don't have control over. Also I don't want to force everyone using this to redeploy the dependency to their local repositories.
Is there a Maven plugin that I could utilize or should I start coding my own?
You may want to see if the outputFileNameMapping parameter of maven war plugin can help you.
I know that I'm replying to an old thread, but I needed to perform the above and found this thread helpful. The way I found to achieve this was to perform a 2 step process:
So, by way of illustration, this is how to specify the file you wish to exclude. In this case x-1.0.jar :
Also specify that a copy must be performed of the file to the new name (x-1.0.final.jar) but this needs to run BEFORE packaging occurs. This is specified by the phase: 'prepare-package':
In my example I wasn't hard-coding 1.0 but I think this should work for the original posters question.
You can use
maven-dependency-plugin
to include artifact under the name that you need.By default,
maven-dependency-plugin
is bound to theprocess-sources
phase that seems just enough for your task. Remember to set the scopeprovided
for the artifact in dependencies so that it is not automatically included by thewar
plugin.Sorry I dont understand your question fully what is the code you have for importing this jar in the POM?
If the Jar you wish to import is called that in the repository and you are importing the correct file in your POM then you shouldn't have to worry about naming conventions of the JAR file.
What i believe you may have to do is rename the file in the repository you can do this simply by going into the Repository Users/.m2 in a explorer window and tracking down the file and renaming it, note this may have implications on other projects.
What i suggest you do is copy the file rename it and add it to the repository with the new artifact id x-1.0.final.jar
fill in the <>
Hope this helps Chris