Skip to content
Advertisement

Maven: Adding classes from war/web-inf/classes as a jar to war/web-inf/lib

I’m rather new to maven here. I have created a Maven Spring boot project with following structure –

JavaScript

As you can see the packaging has been set as war. As such when the war file is generated, my source code’s generated .class files are generated in the war/web-inf/classes folder. Rather than it being generated in classes folder, I’d like to generate it as jar file and maintain it in war/web-inf/lib folder.

I’m guessing I need to make use of the maven-jar-plugin for this. But I’m not sure how to move the generated jar to war/web-inf/lib directory? Is there a simpler alternative to this?

Also how can I restrict the .class files from being generated in war/web-inf/classes folder?

Would really appreciate some pointers. Many thanks.

Advertisement

Answer

This is how the build section of pom should be –

JavaScript

This would restrict the compiled classes from being generated in classes folder while at the same time generate a thin jar of the compiled classes and add it as web-inf/lib/MavenWeb-0.0.1.jar.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement