Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Maven2 Web Application Setup: Legacy Step-by-Step Guide with Build, Jetty, and Site Reporting

Originally published on 2010-07-12; fully revised and updated.

This guide is for engineers maintaining or modernizing legacy Maven2-style Java web projects. You will learn how to bootstrap a project, switch to WAR packaging, run the core Maven lifecycle, use an in-place Jetty development loop, and generate project documentation and quality reports from pom.xml.

maven2-step-by-step

Create a Maven web application skeleton

The original workflow starts from the Maven archetype flow described in the Maven Getting Started Guide:

mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Then add web and resource directories for a typical JSP/Servlet style project:

mkdir -p my-app/src/main/webapps/WEB-INF
mkdir -p my-app/src/main/resources
mkdir -p my-app/src/test/resources
PathUsed in original postPurpose
src/main/webapps/WEB-INFYesWeb app context and deployment descriptors
src/main/resourcesYesApplication resource files on classpath
src/test/resourcesYesTest-only resource files

To produce a web archive instead of a JAR, change packaging from jar to war. The original post also configured the compiler for Java 1.5:

<packaging>war</packaging>

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <source>1.5</source>
        <target>1.5</target>
      </configuration>
    </plugin>
  </plugins>
</build>Code language: HTML, XML (xml)

Core Maven goals you will use daily

CommandWhat it doesTypical use
mvn cleanRemoves generated build outputReset workspace before a fresh build
mvn compileCompiles main Java sourcesQuick compile check
mvn test-compileCompiles test sourcesValidate test code compiles
mvn testRuns unit testsLocal validation before packaging
mvn packageBuilds artifact (JAR/WAR)Create deployable output
mvn installInstalls artifact into local Maven repositoryMake artifact available to local dependent builds
# Common local build sequence
mvn clean test packageCode language: PHP (php)

Run an in-place development loop with Jetty

The original article uses the Maven2 Jetty Plugin to run the app directly from source and shorten edit-build-run feedback cycles.

flowchart LR
    A[Create project] --> B[Add web directories]
    B --> C[Set packaging to war]
    C --> D[Run clean test package]
    D --> E[Start Jetty]
    E --> F[Open app in browser]
    F --> G[Edit code]
    G --> D
    D --> H[Generate site reports]

Legacy Jetty configuration snippet from the original workflow:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty6-plugin</artifactId>
  <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-j2ee_1.4_spec</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</plugin>Code language: HTML, XML (xml)
mvn jetty6:runCode language: CSS (css)

Expected local URL in this setup: http://localhost:8080/my-app.

Generate IDE metadata from pom.xml

The post highlights Maven-driven IDE metadata generation so source paths and dependencies come from the same POM definition.

mvn eclipse:eclipseCode language: CSS (css)

It also notes setting M2_REPO in Eclipse to point to the local repository path (typically ~/.m2/repository).

Build project documentation and reports with Maven Site

Maven can generate a project site and reports from POM metadata and source docs. The original article references DocBook, APT (Almost Plain Text), and FML for FAQ content.

mkdir -p my-app/src/site/apt
mkdir -p my-app/src/site/fml
mkdir -p my-app/src/site/resources/images
touch my-app/src/site/site.xml
mvn site
PluginRole in reporting/siteStandalone command
maven-project-info-reports-pluginProject metadata reports (dependencies, SCM, issue tracking, etc.)Usually run via mvn site
maven-javadoc-pluginAPI documentation generationmvn javadoc:javadoc
maven-jxr-pluginCross-referenced source browsingmvn jxr:jxr
maven-checkstyle-pluginCode style reportingmvn checkstyle:checkstyle
cobertura-maven-pluginTest coverage reportsmvn cobertura:cobertura

The original Cobertura notes mention that a cobertura.ser file may be left in the project root and can be removed with mvn clean.

Original reference links

Best practices and common pitfalls

  • Treat this as a legacy Maven2 baseline; validate plugin goals and coordinates in your current Maven environment.
  • Keep build logic centralized in pom.xml so IDE, CI, packaging, and documentation use the same source of truth.
  • Run mvn clean test frequently to catch classpath and test breakage early.
  • If you rely on mvn site, keep reporting plugins intentionally curated to avoid noisy or stale reports.
  • Document your project conventions (directory layout, Java level, plugin set) in-repo so onboarding does not depend on tribal knowledge.
  • For deployment transport (Wagon and related flows), add explicit environment-specific documentation because the original post does not provide implementation detail.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Maven Learning Resources: A Practical Study Plan with the Better Builds with Maven PDF

The original post shared one Maven book link. This revised guide preserves that resource and adds a practical learning workflow, comparison table, and hands-on Maven commands.

Read More

Maven CLI Options Reference: Practical Flags, Comparisons, and Command Examples

A structured Maven command-line reference for CI/CD and local builds, including option comparisons, workflow guidance, and ready-to-use mvn commands. Based on the original 2013 cheatsheet, updated for readability and operational use.

Read More

Maven Clover for Distributed Java Applications: Instrument, Collect, and Aggregate Coverage

Learn a practical Clover + Maven workflow for distributed test environments. This walkthrough covers instrumentation, remote execution, coverage file collection, and final report generation.

Read More

Maven Reporting Plugins: Configure Site Reports in pom.xml (All, Selective, and reportSets)

Maven reporting plugins generate project documentation during the site lifecycle and are configured in the reporting section of pom.xml. This guide shows how to run all reports, select specific ones, and structure reportSets cleanly.

Read More

Maven Properties Reference: project.*, settings.*, env.*, and Custom POM Values

Maven properties are the backbone of reusable, environment-aware builds. This revised reference explains major property sources, interpolation flow, and practical commands for inspecting real values.

Read More

Maven Profiles in Practice: Definition, Activation, and Reliable Multi-Environment Builds

Maven profiles let you customize one build for multiple environments without cloning POM files. This guide covers profile types, activation methods, CLI usage, and team-safe best practices.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x