Mac Tutorials - Herong's Tutorial Examples - v3.08, by Herong Yang
The Simplest Maven Project File
This section provides a tutorial on how to create a simple project file, pom.xml, to build a Java project with Apache Maven on macOS.
The behavior of the Maven build process is controlled by a project file called pom.xml. POM stands for "Project Object Model".
Here is a simplest Maven pom.xml file for a Java development project. The "source" and "target" properties defines Java versions you want to use. Those versions must be supported by the actual JDK on the macOS.
<?xml version="1.0" encoding="utf-8"?> <project> <modelVersion>4.0.0</modelVersion> <groupId>herong</groupId> <artifactId>hello</artifactId> <version>1.0.0</version> <name>Hello</name> <description>Hello project</description> <properties> <maven.compiler.source>1.13</maven.compiler.source> <maven.compiler.target>1.13</maven.compiler.target> </properties> </project>
This pom.xml should be located in the java project root directory with the following default sub-directories to hold Java source code files for JAR and WAR build target files.
herong$ mkdir -p src/main/java herong$ mkdir -p src/main/webapp
If you want to develop Java programs to test the target Java code, test program source code files needs to be located in another sub-directory:
herong$ mkdir -p src/test/java
When all source code files are ready, you can run the "mvn package" command to build target files and run tests. Target files are automatically stored in the "target" sub-directory:
herong$ /Library/Maven/apache-maven-3.6.2/bin/mvn package ... [INFO] BUILD SUCCESS herong$ ls -l target drwxr-xr-x 3 herong staff 102 Oct 11 08:54 classes drwxr-xr-x 3 herong staff 102 Oct 11 08:45 generated-sources -rw-r--r-- 1 herong staff 1720 Oct 11 09:08 hello-1.0.0.jar drwxr-xr-x 3 herong staff 102 Oct 11 08:23 maven-archiver drwxr-xr-x 3 herong staff 102 Oct 11 08:34 maven-status
Table of Contents
Macintosh OS (Operating System) History
System and Application Processes
Keychain Access - Password Manager
Keychain Access - Certificate Manager
►Develop and Run Java Applications
Install JDK (Java Development Kit) on macOS
►The Simplest Maven Project File
Use "profile" in Maven Project File
Use "parent" in Maven Project File
Install FOP (Formatting Objects Processor) on macOS