K.5. WAR Files

The structure of WAR files is slightly different from the structure of ordinary JAR files. In particular, when constructing a WAR file, the src/resources directory is ignored and the src/web directory is used instead. Anything in src/web is added to the WAR file at its root, just as with src/resources for a JAR file. Other than the name, there is no difference between how these directories are used. Additionally, the src/conf directory is used to populate the WEB-INF directory in the WAR rather than the META-INF. At present, there is no way to add files to META-INF other than manually creating a META-INF directory under src/web. (The MANIFEST.MF file is created automatically by the jar task.) Another difference is that compiled classes go in WEB-INF/classes instead of at the root as with a normal JAR file.

If the abuild.war-type property in Abuild-ant.properties has the value server, we copy all JAR files in the abuild.classpath variable into the WEB-INF/lib directory. If abuild.war-type has the value client, they are copied into the root of the WAR file. Before copying the JAR files from the classpath into the WAR file, abuild places them in the abuild-java/classpath directory. If you need to create a WAR file that includes files from abuild.classpath both at the root and in the WEB-INF/lib directory, create a client WAR file and use a pre-package hook to move some of the files from classpath into src/conf/lib (remember that both of these paths are relative to the output directory, which is directory from which ant is run) so that they will end up in WEB-INF/lib.