Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update a existing war file with additional files using Maven?

I would like to update an open-source war file in Maven with some additional class files and jar files. I also need to replace one configuration file with my own.

The simplest way I see to do this is copy over the Java source files and configuration files from the base war file and check them into my source repository. This would work, but it requires that I duplicate both source and configuration files. Thus, what I would like to do is build the base war file, check in only that war file, then run a maven build which adds my class files, extra jar files, and replaces one configuration file in the base war. The output of the Maven build would be one war file.

Does anybody have any suggestions as to how I can do this with Maven?

By the way, the base file is from jUDDI - it is juddi-war. I think the answer to the problem does not depend on the particular war file though.

like image 500
David V Avatar asked May 18 '11 16:05

David V


People also ask

Can we edit war file?

A "war" file is just a "jar" filw with specific contents. And a "jar" file is essentially just a "zip" file. So you can edit a "war" file by expanding it out to a directory structure using the "jar" command from your java SDK, or you can edit it in-situ using something such as WinZip".

How does maven WAR plugin work?

The Maven WAR plugin is responsible for collecting and compiling all the dependencies, classes, and resources of the web application into a web application archive. There are some defined goals in the Maven WAR plugin: war: This is the default goal that is invoked during the packaging phase of the project.

What is difference between WAR and jar?

JAR files allow us to package multiple files in order to use it as a library, plugin, or any kind of application. On the other hand, WAR files are used only for web applications. The structure of the archives is also different. We can create a JAR with any desired structure.


1 Answers

You'll want to use an overlay. It's intended to add files to an existing WAR.

like image 58
sblundy Avatar answered Oct 28 '22 20:10

sblundy