This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
The commands that can be used with Maven to trigger compiling, building, and testing, among other tasks, are based on the idea of a build lifecycle. In this video, we explore how Maven is composed of lifecycles, phases, and goals.
Maven Phases
See the Maven docs for a list of all phases included in each of the three built-in lifecycles:
- clean
- default
- site
Creating an Executable Java App with Maven
To create an executable JAR with Maven, you can use the shade plugin. Configuring this plugin involves altering pom.xml to include configuration of the plugin, which consists of indicating the main class that should be run when this JAR is executed. After adding this configuration to your POM, you can run the following in your terminal:
mvn shade
Then, you can run the app just like any other executable JAR:
java -jar your-archive-1.0.0-SNAPSHOT.jar
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up