Use "profile" in Maven Project File

This section provides a tutorial on how to use 'profile' in Maven project file to provide options to control the build process.

If you want to have optional Maven build processes, you can add multiple "profile" entries in the project file. This allows you to select a specific "profile" when running the build process.

For example, if you want to build targets with different Java versions, you can add the following "profile" entries

<?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>
  <profiles>
    <profile>
      <id>java-8</id>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
    </profile>
    <profile>
      <id>java-13</id>
      <properties>
        <maven.compiler.source>1.13</maven.compiler.source>
        <maven.compiler.target>1.13</maven.compiler.target>
      </properties>
    </profile>
  </profiles>
  <properties>
  </properties>
</project>

If you want to build the target with Java 13, you can select "java-13" when running the "mvn" command:

herong$ mvn -f pom-profile.xml -P java-13 package

Table of Contents

 About This Book

 Macintosh OS (Operating System) History

 macOS Operating System

 macOS File Systems

 macOS Network Connections

 System and Application Processes

 Keychain Access - Password Manager

 Keychain Access - Certificate Manager

 Productivity Tools on macOS

 Programming Tools on macOS

 Apache Web Server on macOS

Develop and Run Java Applications

 Install JDK (Java Development Kit) on macOS

 Run Java Applet in Safari

 Install Apache Maven 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

 Install Tomcat Java EE Server on macOS

 Full Version in PDF/EPUB