Generate .war file from web app containing just HTML, CSS & JavaScript

css, html, javascript, war

Solution

This is extremely simple:

- Create a folder

- Add a `src/main/webapp` folder

- Add all of your HTML, CSS and JS files to the `src/main/webapp` folder

- Add an empty web.xml file to the `src/main/webapp/WEB-INF` directory.

- add a maven pom.xml

add the maven-war-plugin to your pom.xml, with the following configuration:

<!--  create the war -->
<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
  </configuration>
</plugin>

run mvn clean install!

Problem

I am trying to create a war file that will be deployed on a web/application server. The source files of the app are purely HTML, CSS, and JavaScript. There is a separate war file for our REST API and for the rest of our backend code. Most of the guides out there talk about using java to compile, and pointing to WEB-INF folders etc. However, as I mentioned, in the HTML/CSS/JS war, I don't use any Java, don't use WEB-INF, and there are no servlets or other things you would normally see in a "Java" war file. How do I compile or create this type of war file? The contents look like this: WebContent/HTML WebContent/CSS WebContent/JS All libraries for JavaScript contained within JS folder. Would this work: Simply run: ``` src.dist="./WebContent" app.name="example" app.version=1 work.home="./temp" jar jarfile="${src.dist}/${app.name}-${app.version}.war" basedir="${work.home}" ``` Obviously I would have set up the rest of the script correctly.

Original source