I would like to include all my .class from a dependency jar into WAR classes/ directory instead of having a Jar in lib/ directory.
I have :
my-webapp/
...
WEB-INF/
lib/
mylib-1.0-SNAPSHOT.jar
I would like :
my-webapp/
...
WEB-INF/
classes/
mylib-1.0-SNAPSHOT (all **.class**)
I also see maven-dependency-plugin but it requires that my jar is installed into local or remote repository. But mylib-1.0-SNAPSHOT.jar is compiled juste before my WAR and if If I call mvn package, It’s fail !
So, how to unpack my jar dependency into war classes ? (like maven-shade-plugin for Jar)
I wanted to write this in a commnet, but text is too long.
Sorry, I dont get your point. You have multiple webapps that share classes so you have packaged into a JAR those common classes and now you can distribute the jar and avoid code duplication. That is OK. At this point, for a Webapp, there is no difference between having a class in /WEB-INF/classes or in /WEB-INF/lib/ as part of a jar, the webapp can use the classes in both cases.
With Maven, you should have n project. One for your common jar, and then, one for each webapp you have (where you common jar is a dependency). Before build a WAR for one of your webapp, if common classes have changed, you should first install (in your common repository) the jar:
mvn install. Once jar is installed, you can build your WAR:mvn war:war