I have a dependencies from other projects (.jsp’s, .tag files) that I need in my maven project. To solve this I have created a “resource” jar from these other projects and have specified them as a dependency in maven. I then unzip the jar (in ant, during the generate-sources lifecycle phase) and copy files to where they need to go. This is where the question is (suggestions on a better overall approach are also welcome). I was thinking I could just move these files into the target directory where I want them and they’d be packaged with the war, but that doesn’t work. The common approach seems to be to add an additional resource directory to the war plugin:
How create file and put it in a war with Maven?
Rename a generated file in Maven before building WAR
However, I really don’t want to keep these files around in my source code, since they belong to another project. Is there a way I can include temporary resources into the jar?
I would say that this is a typical case when you should be looking at Maven War Overlay.
It means that you can take pieces of another war and apply to your own war. The best thing would be if all the common resources would be in one parent war that would be used by other wars using the overlay technique.
You add a dependency to the war you want to use as an overlay:
Then you apply it in the
maven-war-plugin: