Essential Maven Commands for Efficient Multi‑Module Projects

This guide compiles the most useful Maven commands and IDE tips for creating, building, packaging, and deploying multi‑module Java projects, covering project structure, command syntax, advanced combinations, and IntelliJ IDEA integrations.

Senior Brother's Insights
Senior Brother's Insights
Senior Brother's Insights
Essential Maven Commands for Efficient Multi‑Module Projects

Background

When automating releases with Maven in large, multi‑module projects, knowing the right commands can dramatically improve productivity. This article collects frequently used Maven commands and practical tips.

Maven Common Commands

Project directory layout:

--P (parent pom)
-- A (module common)
-- B (module biz depends on common)
-- C (module web depends on B, indirectly on A)

Creating Projects

Create a standard Maven project:

mvn archetype:create -DgroupId=packageName -DartifactId=projectName

Create a web Maven project:

mvn archetype:create -DgroupId=packageName -DartifactId=webappName -DarchetypeArtifactId=maven-archetype-webapp

Install a third‑party JAR to the local repository:

mvn install:install-file -DgroupId=xxx.xx.xxxx -DartifactId=xxx -Dversion=0.0.1 -Dpackaging=jar -Dfile=path/xxx-0.0.1.jar

Build and Package Commands

Compile source code: mvn compile Compile test code: mvn test-compile Run tests: mvn test Package the project: mvn package Clean compiled artifacts: mvn clean Clean and package together: mvn clean package Clean and install to local repo: mvn clean install List resolved dependencies (useful for conflict analysis): mvn dependency:list Deploy to a remote repository:

mvn deploy

Complex Combined Commands

Force update of snapshots before packaging: mvn clean package -U Skip unit tests during packaging: mvn clean package -Dmaven.test.skip=true Package with a specific profile (e.g., test environment): mvn clean package -P test Build a specific module and its dependencies: mvn clean install -pl C -am -Dmaven.test.skip=true Build only the parent project: mvn clean install -N Build only module A: mvn clean install -pl A -am Build module A and all modules that depend on it: mvn clean install -pl A -amd Deploy a JAR with tests skipped: mvn clean deploy -Dmaven.test.skip=true Specify an alternative settings file: mvn clean package -s settings.xml Show all Maven help options: mvn -help or

mvn -h

IDEA Maven Operations

In IntelliJ IDEA you can run Maven commands directly from the built‑in Terminal, which starts in the project root and is faster than the IDE’s automatic dependency resolution.

Alternatively, use the Maven tool window to execute goals by double‑clicking them; the refresh icons update the dependency tree.

Disabling Unit Tests in IDEA

Click the lightning icon to skip tests during a build, or select multiple goals with Alt/Command for batch execution.

Conclusion

The compiled list of Maven commands and IDE tips aims to streamline daily development and CI/CD workflows for multi‑module Java projects. Readers are encouraged to share additional useful commands.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaBuild Automationdependency managementmavencommand-lineIDEAMulti‑module
Senior Brother's Insights
Written by

Senior Brother's Insights

A public account focused on workplace, career growth, team management, and self-improvement. The author is the writer of books including 'SpringBoot Technology Insider' and 'Drools 8 Rule Engine: Core Technology and Practice'.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.