For those working with Adobe Experience Manager (AEM) Cloud Service, it’s especially important to ensure your projects are leveraging the most up-to-date Java version. While Adobe Cloud Manager traditionally uses Java 8 for builds, AEM Cloud Service users are encouraged to transition to Java 11. This guide walks through the steps needed to update your Adobe Cloud Manager environment to use Java 11, covering both Maven configuration and Cloud Manager setup.
Common Errors When Upgrading to Java 11 in Adobe Cloud Manager
When upgrading your Adobe Experience Manager environment to use Java 11, you may encounter some common errors and warnings. These issues are often linked to Maven running with a Java version lower than 11, which conflicts with the rules enforced by the maven-enforcer-plugin. Below are examples of errors you might see, along with brief explanations.
- Stack Trace
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message: Maven must be executed with a Java 11 JRE or higher.
Explanation: This warning indicates that Maven is currently using a Java version lower than 11. The maven-enforcer-plugin enforces a minimum Java version requirement for your build process, which triggers this warning when the requirement isn't met. - Stack Trace
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce (enforce-maven) on project:
Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
Explanation:Explanation: This error occurs when one or more rules enforced by the maven-enforcer-plugin fail. The specific cause is usually detailed in the preceding warning messages. These errors are commonly seen when attempting to update your environment to Java 11.
To resolve these issues, follow the steps outlined below. They will guide you to update your Adobe Cloud Manager environment to use Java 11.
Step 1: Updating Maven Configuration to Support Java 11
To align your Maven builds with Java 11, the pom.xml file needs updating. This ensures that Maven is executed using the correct Java version.
Here’s how to update the root pom.xml:
<build>
<plugins>
<!-- Enforce Maven Version -->
<plugin>
<groupId>org.apache.maven.plugins </groupId>
<artifactId>maven-enforcer-plugin </artifactId>
<executions>
<execution>
<goals>
<goal>enforce </goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.3.9,) </version>
</requireMavenVersion>
<requireJavaVersion>
<message>Maven must be executed with a Java 11 JRE or higher. </message>
<version>11 </version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Maven Compiler Plugin -->
<plugin>
<groupId>org.apache.maven.plugins </groupId>
<artifactId>maven-compiler-plugin </artifactId>
<configuration>
<release>11 </release>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<!-- additional configuration if needed -->
</pluginManagement>
</build>
This configuration achieves two primary objectives:
- In the Git branch used by Cloud Manager’s pipeline, create a new file named .cloudmanager/java-version.
- Inside this file, simply include the text 11. This tells Cloud Manager to use Java 11 for builds.
Your .cloudmanager/java-versionfile should look like this:
11
Once Cloud Manager detects this file with the value 11, it will automatically set the JAVA_HOME environment variable to point to Java 11.
Final Thoughts:
Updating to Java 11 in your Adobe Cloud Manager environment is a straightforward yet crucial step to ensure compatibility and support for AEM Cloud Service projects. By following these steps, you’ll ensure that your builds leverage the latest supported Java version, enhancing security, performance, and stability.
If you need help upgrading your Adobe Cloud Manager environment to Java 11 or have any other Adobe Cloud Manager-related needs, connect with us. Our Adobe experts are happy to help you assist in making your transition smooth and successful.