Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

In a previous post I've shown how to put together a simple build system using JWSC. That article is useful, but what if you need to package additional jar files into your web application? This article shows you how.

This article builds on the build system that I've already provided so I'm only going to show the additional parts that need to be added.

First a path element needs to be defined. This will will store the locations of all of the additinal jar files that should be added into the war file. In this example, just one extra jar file is packaged, myextralib.jar.
<path id="war_webinf_lib_path">
<fileset file="${libs.dir}/myextralib.jar"/>

Second, all of the files defined in the path element above need to be assembled into a single directory.
<mkdir dir="${build.dir}/webinf/lib"/>
<copy todir="${build.dir}/webinf/lib">
<path refid="war_webinf_lib_path"/>

Last, a zipfileset element is added into the module element of the jwsc task. This is where the jar files get packaged into the war file.
<!-- Build WAR file using jwsc -->
<jwsc ...>
<module ...>
<jws .../>
<zipfileset prefix="WEB-INF/lib" dir="${build.dir}/webinf/lib"/>

A quick and easy addition. Enjoy!


A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.