You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2018/03/10 13:00:43 UTC

[maven-javadoc-plugin] 01/01: [MJAVADOC-517] NPE under Java 10 RC Replace JavadocVersion with JavaVersion from plexus-java Extract parts from commons-lang3 SystemUtils, which should not be used anymore; it uses enums for java versions, which means an update is required for every new Java version.

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MJAVADOC-517
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git

commit c922342ed87805c236d68ccbf545efb17af0f965
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Mar 10 14:00:32 2018 +0100

    [MJAVADOC-517] NPE under Java 10 RC
    Replace JavadocVersion with JavaVersion from plexus-java
    Extract parts from commons-lang3 SystemUtils, which should not be used anymore; it uses enums for java versions, which means an update is required for every new Java version.
---
 pom.xml                                            |   2 +-
 .../maven/plugins/javadoc/AbstractJavadocMojo.java |  38 ++---
 .../apache/maven/plugins/javadoc/JavadocUtil.java  |  11 +-
 .../maven/plugins/javadoc/JavadocVersion.java      |   2 +
 .../apache/maven/plugins/javadoc/SystemUtils.java  | 181 +++++++++++++++++++++
 .../maven/plugins/javadoc/FixJavadocMojoTest.java  |   8 +-
 .../maven/plugins/javadoc/JavadocJarTest.java      |  10 +-
 .../maven/plugins/javadoc/JavadocReportTest.java   |  10 +-
 8 files changed, 219 insertions(+), 43 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5de8896..e646e70 100644
--- a/pom.xml
+++ b/pom.xml
@@ -234,7 +234,7 @@ under the License.
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-java</artifactId>
-      <version>0.9.5</version>
+      <version>0.9.6</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index b403c00..24ea1b9 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -20,8 +20,6 @@ package org.apache.maven.plugins.javadoc;
  */
 
 import org.apache.commons.lang3.ClassUtils;
-import org.apache.commons.lang3.JavaVersion;
-import org.apache.commons.lang3.SystemUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.handler.ArtifactHandler;
@@ -86,6 +84,7 @@ import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelecto
 import org.codehaus.plexus.languages.java.jpms.LocationManager;
 import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
 import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
@@ -256,7 +255,7 @@ public abstract class AbstractJavadocMojo
      *
      * @since 2.1
      */
-    private static final JavadocVersion SINCE_JAVADOC_1_4 = JavadocVersion.parse( "1.4" );
+    private static final JavaVersion SINCE_JAVADOC_1_4 = JavaVersion.parse( "1.4" );
 
     /**
      * For Javadoc options appears since Java 1.4.2.
@@ -266,7 +265,7 @@ public abstract class AbstractJavadocMojo
      *
      * @since 2.1
      */
-    private static final JavadocVersion SINCE_JAVADOC_1_4_2 = JavadocVersion.parse( "1.4.2" );
+    private static final JavaVersion SINCE_JAVADOC_1_4_2 = JavaVersion.parse( "1.4.2" );
 
     /**
      * For Javadoc options appears since Java 5.0.
@@ -276,7 +275,7 @@ public abstract class AbstractJavadocMojo
      *
      * @since 2.1
      */
-    private static final JavadocVersion SINCE_JAVADOC_1_5 = JavadocVersion.parse( "1.5" );
+    private static final JavaVersion SINCE_JAVADOC_1_5 = JavaVersion.parse( "1.5" );
 
     /**
      * For Javadoc options appears since Java 6.0.
@@ -285,7 +284,7 @@ public abstract class AbstractJavadocMojo
      *
      * @since 2.4
      */
-    private static final JavadocVersion SINCE_JAVADOC_1_6 = JavadocVersion.parse( "1.6" );
+    private static final JavaVersion SINCE_JAVADOC_1_6 = JavaVersion.parse( "1.6" );
 
     /**
      * For Javadoc options appears since Java 8.0.
@@ -294,13 +293,12 @@ public abstract class AbstractJavadocMojo
      *
      * @since 3.0.0
      */
-    private static final JavadocVersion SINCE_JAVADOC_1_8 = JavadocVersion.parse( "1.8" );
+    private static final JavaVersion SINCE_JAVADOC_1_8 = JavaVersion.parse( "1.8" );
 
     /**
      * 
      */
-    // JAVA_VERSION can have -ea suffix, which is not supported (yet)
-    private static final JavadocVersion JAVA_VERSION = JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION );
+    private static final JavaVersion JAVA_VERSION = JavaVersion.JAVA_SPECIFICATION_VERSION;
 
     // ----------------------------------------------------------------------
     // Mojo components
@@ -490,7 +488,7 @@ public abstract class AbstractJavadocMojo
     /**
      * Version of the Javadoc Tool executable to use.
      */
-    private JavadocVersion javadocRuntimeVersion;
+    private JavaVersion javadocRuntimeVersion;
 
     /**
      * Specifies whether the Javadoc generation should be skipped.
@@ -3689,7 +3687,7 @@ public abstract class AbstractJavadocMojo
         }
         // For Apple's JDK 1.6.x (and older?) on Mac OSX
         // CHECKSTYLE_OFF: MagicNumber
-        else if ( SystemUtils.IS_OS_MAC_OSX && !SystemUtils.isJavaVersionAtLeast( JavaVersion.JAVA_1_7 ) )
+        else if ( SystemUtils.IS_OS_MAC_OSX && !JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "1.7" ) )
         // CHECKSTYLE_ON: MagicNumber
         {
             javadocExe = new File( SystemUtils.getJavaHome() + File.separator + "bin", javadocCommand );
@@ -3740,7 +3738,7 @@ public abstract class AbstractJavadocMojo
     private void setFJavadocVersion( File jExecutable )
         throws MavenReportException
     {
-        JavadocVersion jVersion;
+        JavaVersion jVersion;
         try
         {
             jVersion = JavadocUtil.getJavadocVersion( jExecutable );
@@ -3777,7 +3775,7 @@ public abstract class AbstractJavadocMojo
         {
             try
             {
-                javadocRuntimeVersion = JavadocVersion.parse( javadocVersion );
+                javadocRuntimeVersion = JavaVersion.parse( javadocVersion );
             }
             catch ( NumberFormatException e )
             {
@@ -3802,7 +3800,7 @@ public abstract class AbstractJavadocMojo
      * @return <code>true</code> if the javadoc version is equal or greater than the
      *         required version
      */
-    private boolean isJavaDocVersionAtLeast( JavadocVersion requiredVersion )
+    private boolean isJavaDocVersionAtLeast( JavaVersion requiredVersion )
     {
         return JAVA_VERSION.compareTo( requiredVersion ) >= 0;
     }
@@ -3834,7 +3832,7 @@ public abstract class AbstractJavadocMojo
      * @see #addArgIf(java.util.List, boolean, String)
      * @see #isJavaDocVersionAtLeast(float)
      */
-    private void addArgIf( List<String> arguments, boolean b, String value, JavadocVersion requiredJavaVersion )
+    private void addArgIf( List<String> arguments, boolean b, String value, JavaVersion requiredJavaVersion )
     {
         if ( b )
         {
@@ -3885,7 +3883,7 @@ public abstract class AbstractJavadocMojo
      * @see #isJavaDocVersionAtLeast(float)
      */
     private void addArgIfNotEmpty( List<String> arguments, String key, String value, boolean repeatKey,
-                                   boolean splitValue, JavadocVersion requiredJavaVersion )
+                                   boolean splitValue, JavaVersion requiredJavaVersion )
     {
         if ( StringUtils.isNotEmpty( value ) )
         {
@@ -3978,7 +3976,7 @@ public abstract class AbstractJavadocMojo
      * @see #addArgIfNotEmpty(java.util.List, String, String, float, boolean)
      */
     private void addArgIfNotEmpty( List<String> arguments, String key, String value,
-                                   JavadocVersion requiredJavaVersion )
+                                   JavaVersion requiredJavaVersion )
     {
         addArgIfNotEmpty( arguments, key, value, requiredJavaVersion, false );
     }
@@ -3995,7 +3993,7 @@ public abstract class AbstractJavadocMojo
      * @see #addArgIfNotEmpty(java.util.List, String, String)
      * @see #isJavaDocVersionAtLeast(float)
      */
-    private void addArgIfNotEmpty( List<String> arguments, String key, String value, JavadocVersion requiredJavaVersion,
+    private void addArgIfNotEmpty( List<String> arguments, String key, String value, JavaVersion requiredJavaVersion,
                                    boolean repeatKey )
     {
         if ( StringUtils.isNotEmpty( value ) )
@@ -5753,13 +5751,13 @@ public abstract class AbstractJavadocMojo
         }
 
         final String pluginId = "org.apache.maven.plugins:maven-compiler-plugin";
-        JavadocVersion sourceVersion = javadocRuntimeVersion;
+        JavaVersion sourceVersion = javadocRuntimeVersion;
         String sourceConfigured = getPluginParameter( project, pluginId, "source" );
         if ( sourceConfigured != null )
         {
             try
             {
-                sourceVersion = JavadocVersion.parse( sourceConfigured );
+                sourceVersion = JavaVersion.parse( sourceConfigured );
             }
             catch ( NumberFormatException e )
             {
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index e60699f..ec1a4f7 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -19,7 +19,6 @@ package org.apache.maven.plugins.javadoc;
  * under the License.
  */
 
-import org.apache.commons.lang3.SystemUtils;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
@@ -49,6 +48,7 @@ import org.apache.maven.shared.invoker.MavenInvocationException;
 import org.apache.maven.shared.invoker.PrintStreamHandler;
 import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.proxy.ProxyUtils;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
@@ -514,7 +514,7 @@ public class JavadocUtil
      * @throws PatternSyntaxException if the output contains a syntax error in the regular-expression pattern.
      * @see #extractJavadocVersion(String)
      */
-    protected static JavadocVersion getJavadocVersion( File javadocExe )
+    protected static JavaVersion getJavadocVersion( File javadocExe )
         throws IOException, CommandLineException, IllegalArgumentException
     {
         if ( ( javadocExe == null ) || ( !javadocExe.exists() ) || ( !javadocExe.isFile() ) )
@@ -542,11 +542,11 @@ public class JavadocUtil
 
         if ( StringUtils.isNotEmpty( err.getOutput() ) )
         {
-            return JavadocVersion.parse( extractJavadocVersion( err.getOutput() ) );
+            return JavaVersion.parse( extractJavadocVersion( err.getOutput() ) );
         }
         else if ( StringUtils.isNotEmpty( out.getOutput() ) )
         {
-            return JavadocVersion.parse( extractJavadocVersion( out.getOutput() ) );
+            return JavaVersion.parse( extractJavadocVersion( out.getOutput() ) );
         }
 
         throw new IllegalArgumentException( "No output found from the command line 'javadoc -J-version'" );
@@ -1298,8 +1298,7 @@ public class JavadocUtil
         if ( System.getProperty( "maven.home" ) == null || javaHomeValue == null )
         {
             // JEP220 (Java9) restructured the JRE/JDK runtime image
-            if ( ( SystemUtils.IS_OS_MAC_OSX
-                || JavadocVersion.parse( SystemUtils.JAVA_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 ) )
+            if ( SystemUtils.IS_OS_MAC_OSX || JavaVersion.JAVA_VERSION.isAtLeast( "9" ) )
             {
                 javaHome = SystemUtils.getJavaHome();
             }
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java
index 3a6fd16..27661b9 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocVersion.java
@@ -30,7 +30,9 @@ import org.codehaus.plexus.util.StringUtils;
  * 
  * @author Robert Scholte
  * @since 3.0.0
+ * @deprecated Use {@link org.codehaus.plexus.languages.java.version.JavaVersion} instead
  */
+@Deprecated
 public class JavadocVersion implements Comparable<JavadocVersion>
 {
     private String rawVersion;
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/SystemUtils.java b/src/main/java/org/apache/maven/plugins/javadoc/SystemUtils.java
new file mode 100644
index 0000000..84675b3
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/javadoc/SystemUtils.java
@@ -0,0 +1,181 @@
+package org.apache.maven.plugins.javadoc;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+/**
+ * Contains several OS-specific methods from Commons-Lang3's SystemUtils. We don't want to use that class because it
+ * uses enums for Java versions, which implies that with every new Java version a new commons-lang3 is required.
+ * 
+ * @author Robert Scholte
+ * @since 3.0.1
+ */
+class SystemUtils
+{
+    /**
+     * <p>
+     * The {@code os.name} System Property. Operating system name.
+     * </p>
+     * <p>
+     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does
+     * not exist.
+     * </p>
+     * <p>
+     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or
+     * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of
+     * sync with that System property.
+     * </p>
+     *
+     * @since Java 1.1
+     */
+    public static final String OS_NAME = getSystemProperty( "os.name" );
+
+    /**
+     * The prefix String for all Windows OS.
+     */
+    private static final String OS_NAME_WINDOWS_PREFIX = "Windows";
+
+    /**
+     * <p>
+     * Is {@code true} if this is AIX.
+     * </p>
+     * <p>
+     * The field will return {@code false} if {@code OS_NAME} is {@code null}.
+     * </p>
+     */
+    public static final boolean IS_OS_AIX = getOSMatchesName( "AIX" );
+
+    /**
+     * <p>
+     * Is {@code true} if this is Mac.
+     * </p>
+     * <p>
+     * The field will return {@code false} if {@code OS_NAME} is {@code null}.
+     * </p>
+     */
+    public static final boolean IS_OS_MAC_OSX = getOSMatchesName( "Mac OS X" );
+
+    /**
+     * <p>
+     * Is {@code true} if this is Windows.
+     * </p>
+     * <p>
+     * The field will return {@code false} if {@code OS_NAME} is {@code null}.
+     * </p>
+     */
+    public static final boolean IS_OS_WINDOWS = getOSMatchesName( OS_NAME_WINDOWS_PREFIX );
+
+    /**
+     * The System property key for the Java home directory.
+     */
+    private static final String JAVA_HOME_KEY = "java.home";
+
+    /**
+     * <p>
+     * The {@code line.separator} System Property. Line separator (<code>&quot;\n&quot;</code> on UNIX).
+     * </p>
+     * <p>
+     * Defaults to {@code null} if the runtime does not have security access to read this property or the property does
+     * not exist.
+     * </p>
+     * <p>
+     * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)} or
+     * {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value will be out of
+     * sync with that System property.
+     * </p>
+     *
+     * @since Java 1.1
+     */
+    public static final String LINE_SEPARATOR = getSystemProperty( "line.separator" );
+
+    /**
+     * Decides if the operating system matches.
+     *
+     * @param osNamePrefix the prefix for the os name
+     * @return true if matches, or false if not or can't determine
+     */
+    private static boolean getOSMatchesName( final String osNamePrefix )
+    {
+        return isOSNameMatch( OS_NAME, osNamePrefix );
+    }
+
+    /**
+     * Decides if the operating system matches.
+     * <p>
+     * This method is package private instead of private to support unit test invocation.
+     * </p>
+     *
+     * @param osName the actual OS name
+     * @param osNamePrefix the prefix for the expected OS name
+     * @return true if matches, or false if not or can't determine
+     */
+    static boolean isOSNameMatch( final String osName, final String osNamePrefix )
+    {
+        if ( osName == null )
+        {
+            return false;
+        }
+        return osName.startsWith( osNamePrefix );
+    }
+
+    /**
+     * <p>
+     * Gets the Java home directory as a {@code File}.
+     * </p>
+     *
+     * @return a directory
+     * @throws SecurityException if a security manager exists and its {@code checkPropertyAccess} method doesn't allow
+     *             access to the specified system property.
+     * @see System#getProperty(String)
+     * @since 2.1
+     */
+    public static File getJavaHome()
+    {
+        return new File( System.getProperty( JAVA_HOME_KEY ) );
+    }
+
+    /**
+     * <p>
+     * Gets a System property, defaulting to {@code null} if the property cannot be read.
+     * </p>
+     * <p>
+     * If a {@code SecurityException} is caught, the return value is {@code null} and a message is written to
+     * {@code System.err}.
+     * </p>
+     *
+     * @param property the system property name
+     * @return the system property value or {@code null} if a security problem occurs
+     */
+    private static String getSystemProperty( final String property )
+    {
+        try
+        {
+            return System.getProperty( property );
+        }
+        catch ( final SecurityException ex )
+        {
+            // we are not allowed to look at this property
+            System.err.println( "Caught a SecurityException reading the system property '" + property
+                + "'; the SystemUtils property value will default to null." );
+            return null;
+        }
+    }
+}
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
index 9578f58..94a8142 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java
@@ -28,12 +28,12 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 
-import org.apache.commons.lang3.SystemUtils;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.plugins.javadoc.AbstractFixJavadocMojo.JavaEntityTags;
 import org.apache.maven.shared.invoker.MavenInvocationException;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
@@ -150,7 +150,7 @@ public class FixJavadocMojoTest
     {
         // Should be an assumption, but not supported by TestCase
         // Java 5 not supported by Java9 anymore
-        if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
+        if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
         {
             return;
         }
@@ -649,11 +649,9 @@ public class FixJavadocMojoTest
         invokerDir.mkdirs();
         File invokerLogFile = FileUtils.createTempFile( "FixJavadocMojoTest", ".txt", invokerDir );
         
-        JavadocVersion JAVA_9 = JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION );
-        
         Properties properties = new Properties();
         
-        if( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JAVA_9 ) >= 0 )
+        if( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
         {
             properties.put( "maven.compiler.source", "1.6" );
             properties.put( "maven.compiler.target", "1.6" );
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
index e066e47..18e71cc 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocJarTest.java
@@ -33,10 +33,8 @@ import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.apache.maven.plugins.javadoc.AbstractJavadocMojo;
-import org.apache.maven.plugins.javadoc.JavadocJar;
-import org.apache.maven.plugins.javadoc.JavadocVersion;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -96,12 +94,12 @@ public class JavadocJarTest
         }
 
         assertTrue( set.contains( "stylesheet.css" ) );
-        JavadocVersion javadocVersion = (JavadocVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
-        if ( javadocVersion.compareTo( JavadocVersion.parse( "1.7" ) ) < 0 )
+        JavaVersion javadocVersion = (JavaVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
+        if ( javadocVersion.isBefore( "1.7" ) )
         {
             assertTrue( set.contains( "resources/inherit.gif" ) );
         }
-        else if ( javadocVersion.compareTo( JavadocVersion.parse( "1.8" ) ) < 0 )
+        else if ( javadocVersion.isBefore( "1.8" ) )
         {
             assertTrue( set.contains( "resources/background.gif" ) /* JDK7 */);
         }
diff --git a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
index a521839..f21e063 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
@@ -33,7 +33,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang3.SystemUtils;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.LegacySupport;
@@ -47,6 +46,7 @@ import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.repository.internal.MavenRepositorySystemSession;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.languages.java.version.JavaVersion;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
@@ -315,7 +315,7 @@ public class JavadocReportTest
     {
         // Should be an assumption, but not supported by TestCase
         // Seems like a bug in Javadoc 9
-        if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) == 0 )
+        if ( JavaVersion.JAVA_SPECIFICATION_VERSION.compareTo( JavaVersion.parse( "9" ) ) == 0 )
         {
             return;
         }
@@ -578,7 +578,7 @@ public class JavadocReportTest
     {
         // Should be an assumption, but not supported by TestCase
         // Java 5 not supported by Java9 anymore
-        if ( JavadocVersion.parse( SystemUtils.JAVA_SPECIFICATION_VERSION ).compareTo( JavadocVersion.parse( "9" ) ) >= 0 )
+        if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" ) )
         {
             return;
         }
@@ -660,8 +660,8 @@ public class JavadocReportTest
         content = readFile( app );
         assertTrue( content.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) );
 
-        JavadocVersion javadocVersion = (JavadocVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
-        if( javadocVersion.compareTo( JavadocVersion.parse( "1.8" ) ) >= 0  && javadocVersion.compareTo( JavadocVersion.parse( "10" ) ) < 0)
+        JavaVersion javadocVersion = (JavaVersion) getVariableValueFromObject( mojo, "javadocRuntimeVersion" );
+        if( javadocVersion.isAtLeast( "1.8" ) && javadocVersion.isBefore( "10" ) )
         {
             // https://bugs.openjdk.java.net/browse/JDK-8032205
             assertTrue( "Javadoc runtime version: " + javadocVersion

-- 
To stop receiving notification emails like this one, please contact
rfscholte@apache.org.