7.1. Maven Introduction

Maven is one of many “build tools” available for the Java language. A build tool is a program that scripts or automates the process of cleaning, compiling, running, and packaging code. So long as your source code adheres to a proper package structure (i.e., proper package directory structure and package statements), then Maven can usually figure out the rest – even with dependencies!

Maven has many benefits beyond basic Unix shell scripting (as we’ve been using so far) and is commonly used in large scale applications. While shell scripting is useful in a wide variety of situations, Maven is a more powerful option for compiling your Java projects.

Maven should already be installed and set up on Odin. To confirm that Apache Maven is installed correctly, type the following command:

mvn --version

It should print out your installed version of Maven, for example:

Note: The exact output you see (including version number) may differ.
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /usr/local/mepcott/cs1302/apache-maven
Java version: 17.0.4.1, vendor: Oracle Corporation, runtime: /usr/local/mepcott/jdk/jdk-17.0.4.1
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.42.2.el7.x86_64", arch: "amd64", family: "unix"

If you are on Odin and the mvn command is not recognized, then please ensure that you have set up the CSCI 1302 shell profile according to the instructions provided here.