You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2019/12/22 20:21:31 UTC

[maven] branch MNG-6829 created (now 3307f16)

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

khmarbaise pushed a change to branch MNG-6829
in repository https://gitbox.apache.org/repos/asf/maven.git.


      at 3307f16  WIP - [MNG-6829] - First step.  - Using maven-shared-utils as replacement.  - Added maven-utils which contains some needed implementation    which could be moved later to maven-shared-utils.

This branch includes the following new commits:

     new 3307f16  WIP - [MNG-6829] - First step.  - Using maven-shared-utils as replacement.  - Added maven-utils which contains some needed implementation    which could be moved later to maven-shared-utils.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven] 01/01: WIP - [MNG-6829] - First step. - Using maven-shared-utils as replacement. - Added maven-utils which contains some needed implementation which could be moved later to maven-shared-utils.

Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MNG-6829
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 3307f16c1e8ebd78dfa9ab3a7c46d8a51161dc50
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sat Dec 21 16:00:28 2019 +0100

    WIP - [MNG-6829] - First step.
     - Using maven-shared-utils as replacement.
     - Added maven-utils which contains some needed implementation
       which could be moved later to maven-shared-utils.
---
 maven-artifact/pom.xml                             |   8 +-
 .../org/apache/maven/artifact/ArtifactUtils.java   |   4 +-
 .../versioning/DefaultArtifactVersion.java         |   6 +-
 maven-core/pom.xml                                 |   8 +-
 .../DefaultBeanConfigurationRequest.java           |   6 +-
 .../rtinfo/internal/DefaultRuntimeInformation.java |  16 +-
 maven-embedder/pom.xml                             |   8 +-
 .../org/apache/maven/cli/CLIReportingUtils.java    |   6 +-
 .../transfer/AbstractMavenTransferListener.java    |  13 +-
 .../cli/transfer/ConsoleMavenTransferListener.java |   2 +-
 maven-model-builder/pom.xml                        |   4 +
 .../maven/model/building/FileModelSourceTest.java  |   9 +-
 {maven-artifact => maven-utils}/pom.xml            |  46 +---
 .../java/org/apache/maven/utils/Precondition.java  | 263 +++++++++++++++++++++
 .../java/org/apache/maven/utils/StringUtils.java   |  61 +++++
 .../org/apache/maven/utils/PreconditionTest.java   |  34 +++
 pom.xml                                            |  24 +-
 17 files changed, 436 insertions(+), 82 deletions(-)

diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml
index 336505b..5bc1059 100644
--- a/maven-artifact/pom.xml
+++ b/maven-artifact/pom.xml
@@ -34,12 +34,12 @@ under the License.
 
   <dependencies>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-utils</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-lang3</artifactId>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
     </dependency>
   </dependencies>
 
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
index bd76edd..01c1601 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
@@ -26,8 +26,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 
-import org.apache.commons.lang3.Validate;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.utils.Precondition;
 
 /**
  * ArtifactUtils
@@ -104,7 +104,7 @@ public final class ArtifactUtils
         int c = str != null && str.length() > 0 ? str.charAt( 0 ) : 0;
         if ( ( c < '0' || c > '9' ) && ( c < 'a' || c > 'z' ) )
         {
-            Validate.notBlank( str, message );
+            Precondition.notBlank( str, message );
         }
     }
 
diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
index 75b19fa..d2a185d 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/DefaultArtifactVersion.java
@@ -21,7 +21,7 @@ package org.apache.maven.artifact.versioning;
 
 import java.util.StringTokenizer;
 
-import static org.apache.commons.lang3.math.NumberUtils.isDigits;
+import org.apache.maven.utils.Precondition;
 
 /**
  * Default implementation of artifact versioning.
@@ -188,7 +188,7 @@ public class DefaultArtifactVersion
             if ( tok.hasMoreTokens() )
             {
                 qualifier = tok.nextToken();
-                fallback = isDigits( qualifier );
+                fallback = Precondition.isDigits( qualifier );
             }
 
             // string tokenizer won't detect these and ignores them
@@ -222,7 +222,7 @@ public class DefaultArtifactVersion
     private static Integer tryParseInt( String s )
     {
         // for performance, check digits instead of relying later on catching NumberFormatException
-        if ( !isDigits( s ) )
+        if ( !Precondition.isDigits( s ) )
         {
             return null;
         }
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index 8b70b27..abe6c8d 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -89,6 +89,10 @@ under the License.
       <artifactId>maven-resolver-util</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-utils</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-shared-utils</artifactId>
     </dependency>
@@ -123,10 +127,6 @@ under the License.
       <artifactId>plexus-component-annotations</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-lang3</artifactId>
-    </dependency>
-    <dependency>
       <groupId>commons-jxpath</groupId>
       <artifactId>commons-jxpath</artifactId>
       <scope>test</scope>
diff --git a/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java b/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
index 5ec69f5..1730aaa 100644
--- a/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
+++ b/maven-core/src/main/java/org/apache/maven/configuration/DefaultBeanConfigurationRequest.java
@@ -19,12 +19,12 @@ package org.apache.maven.configuration;
  * under the License.
  */
 
-import org.apache.commons.lang3.Validate;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.PluginExecution;
 import org.apache.maven.model.PluginManagement;
+import org.apache.maven.utils.Precondition;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -121,8 +121,8 @@ public class DefaultBeanConfigurationRequest
 
     private Plugin findPlugin( Model model, String groupId, String artifactId )
     {
-        Validate.notBlank( groupId, "groupId can neither be null, empty nor blank" );
-        Validate.notBlank( artifactId, "artifactId can neither be null, empty nor blank" );
+        Precondition.notBlank( groupId, "groupId can neither be null, empty nor blank" );
+        Precondition.notBlank( artifactId, "artifactId can neither be null, empty nor blank" );
 
         if ( model != null )
         {
diff --git a/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java b/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java
index 12a6b6f..cda5ca1 100644
--- a/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java
+++ b/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java
@@ -19,9 +19,13 @@ package org.apache.maven.rtinfo.internal;
  * under the License.
  */
 
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.Validate;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
 import org.apache.maven.rtinfo.RuntimeInformation;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.utils.Precondition;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.Logger;
@@ -31,10 +35,6 @@ import org.eclipse.aether.version.Version;
 import org.eclipse.aether.version.VersionConstraint;
 import org.eclipse.aether.version.VersionScheme;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
 /**
  * Provides information about the current Maven runtime.
  */
@@ -100,7 +100,7 @@ public class DefaultRuntimeInformation
     {
         VersionScheme versionScheme = new GenericVersionScheme();
 
-        Validate.notBlank( versionRange, "versionRange can neither be null, empty nor blank" );
+        Precondition.notBlank( versionRange, "versionRange can neither be null, empty nor blank" );
 
         VersionConstraint constraint;
         try
@@ -116,7 +116,7 @@ public class DefaultRuntimeInformation
         try
         {
             String mavenVersion = getMavenVersion();
-            Validate.validState( StringUtils.isNotEmpty( mavenVersion ), "Could not determine current Maven version" );
+            Precondition.isTrue( StringUtils.isNotEmpty( mavenVersion ), "Could not determine current Maven version" );
 
             current = versionScheme.parseVersion( mavenVersion );
         }
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index 235ae62..9c7338d 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -63,6 +63,10 @@ under the License.
       <artifactId>maven-builder-support</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-utils</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven.resolver</groupId>
       <artifactId>maven-resolver-api</artifactId>
     </dependency>
@@ -158,10 +162,6 @@ under the License.
       <artifactId>commons-cli</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-lang3</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
       <scope>test</scope>
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
index d562c88..7ca92b8 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java
@@ -19,8 +19,6 @@ package org.apache.maven.cli;
  * under the License.
  */
 
-import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
@@ -28,10 +26,12 @@ import java.util.Date;
 import java.util.Locale;
 import java.util.Properties;
 
-import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.shared.utils.StringUtils;
 import org.codehaus.plexus.util.Os;
 import org.slf4j.Logger;
 
+import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
+
 /**
  * Utility class used to report errors, statistics, application version info, etc.
  *
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
index 984902e..820b2e8 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java
@@ -24,7 +24,7 @@ import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.Locale;
 
-import org.apache.commons.lang3.Validate;
+import org.apache.maven.utils.Precondition;
 import org.eclipse.aether.transfer.AbstractTransferListener;
 import org.eclipse.aether.transfer.TransferCancelledException;
 import org.eclipse.aether.transfer.TransferEvent;
@@ -116,7 +116,7 @@ public abstract class AbstractMavenTransferListener
 
             public static ScaleUnit getScaleUnit( long size )
             {
-                Validate.isTrue( size >= 0L, "file size cannot be negative: %s", size );
+                Precondition.greaterOrEqualToZero(  size, "file size cannot be negative: %s", size );
 
                 if ( size >= GIGABYTE.bytes() )
                 {
@@ -159,7 +159,7 @@ public abstract class AbstractMavenTransferListener
         @SuppressWarnings( "checkstyle:magicnumber" )
         public String format( long size, ScaleUnit unit, boolean omitSymbol )
         {
-            Validate.isTrue( size >= 0L, "file size cannot be negative: %s", size );
+            Precondition.greaterOrEqualToZero( size, "file size cannot be negative: %s", size );
 
             if ( unit == null )
             {
@@ -191,9 +191,10 @@ public abstract class AbstractMavenTransferListener
 
         public String formatProgress( long progressedSize, long size )
         {
-            Validate.isTrue( progressedSize >= 0L, "progressed file size cannot be negative: %s", progressedSize );
-            Validate.isTrue( size >= 0L && progressedSize <= size || size < 0L,
-                "progressed file size cannot be greater than size: %s > %s", progressedSize, size );
+            Precondition.greaterOrEqualToZero( progressedSize, "progressed file size cannot be negative: %s",
+                    progressedSize );
+            Precondition.isTrue( size >= 0L && progressedSize <= size || size < 0L,
+                    "progressed file size cannot be greater than size: %s > %s", progressedSize, size );
 
             if ( size >= 0L && progressedSize != size )
             {
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
index 1ad943b..e9195fb 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java
@@ -26,7 +26,7 @@ import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
 
-import org.apache.commons.lang3.StringUtils;
+import org.apache.maven.utils.StringUtils;
 import org.eclipse.aether.transfer.TransferCancelledException;
 import org.eclipse.aether.transfer.TransferEvent;
 import org.eclipse.aether.transfer.TransferResource;
diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml
index a2145d2..ceec5dd 100644
--- a/maven-model-builder/pom.xml
+++ b/maven-model-builder/pom.xml
@@ -39,6 +39,10 @@ under the License.
       <artifactId>plexus-utils</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-shared-utils</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-interpolation</artifactId>
     </dependency>
diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java
index 9b0ecd9..dc5bb68 100644
--- a/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java
+++ b/maven-model-builder/src/test/java/org/apache/maven/model/building/FileModelSourceTest.java
@@ -18,13 +18,16 @@ package org.apache.maven.model.building;
  * specific language governing permissions and limitations
  * under the License.
  */
+
 import java.io.File;
 import java.io.IOException;
+
+import org.apache.maven.shared.utils.Os;
+import org.junit.Test;
+
 import static junit.framework.TestCase.assertFalse;
 import static junit.framework.TestCase.assertTrue;
-import org.apache.commons.lang3.SystemUtils;
 import static org.junit.Assume.assumeTrue;
-import org.junit.Test;
 
 /**
  * Test that validate the solution of MNG-6261 issue
@@ -53,7 +56,7 @@ public class FileModelSourceTest
     public void testWindowsPaths() 
             throws Exception 
     {
-        assumeTrue( SystemUtils.IS_OS_WINDOWS );
+        assumeTrue( Os.isFamily( Os.FAMILY_WINDOWS ) );
 
         File upperCaseFile = createTempFile( "TESTE" );
         String absolutePath = upperCaseFile.getAbsolutePath();
diff --git a/maven-artifact/pom.xml b/maven-utils/pom.xml
similarity index 50%
copy from maven-artifact/pom.xml
copy to maven-utils/pom.xml
index 336505b..ec67f14 100644
--- a/maven-artifact/pom.xml
+++ b/maven-utils/pom.xml
@@ -19,7 +19,8 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
@@ -28,46 +29,21 @@ under the License.
     <version>3.7.0-SNAPSHOT</version>
   </parent>
 
-  <artifactId>maven-artifact</artifactId>
+  <artifactId>maven-utils</artifactId>
 
-  <name>Maven Artifact</name>
+  <name>Maven Utils</name>
 
   <dependencies>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-lang3</artifactId>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <scope>test</scope>
     </dependency>
-  </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <configuration>
-          <archive>
-            <manifestEntries>
-              <Main-Class>org.apache.maven.artifact.versioning.ComparableVersion</Main-Class>
-            </manifestEntries>
-          </archive>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-failsafe-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>integration-test</goal>
-              <goal>verify</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
+  </dependencies>
 </project>
diff --git a/maven-utils/src/main/java/org/apache/maven/utils/Precondition.java b/maven-utils/src/main/java/org/apache/maven/utils/Precondition.java
new file mode 100644
index 0000000..e731d8d
--- /dev/null
+++ b/maven-utils/src/main/java/org/apache/maven/utils/Precondition.java
@@ -0,0 +1,263 @@
+package org.apache.maven.utils;
+
+/*
+ * 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.util.List;
+
+/**
+ * Convenient utility methods for assertion of different conditions.
+ *
+ * @author Karl Heinz Marbaise
+ */
+public final class Precondition
+{
+    private Precondition()
+    {
+        // no-op
+    }
+
+    /**
+     * assert that the given {@code obj} is not {@code null}.
+     *
+     * @param obj     The instance which should be not {@code null}.
+     * @param message The message will be part of the exception.
+     * @return The supplied object as convenient.
+     */
+    public static <T> T requireNotNull( T obj, String message )
+    {
+        if ( obj == null )
+        {
+            throw new IllegalArgumentException( message );
+        }
+        return obj;
+    }
+
+    /**
+     * assert that the given {@code List<T>} is not {@code empty}.
+     *
+     * @param obj     The instance which should be not {@code empty}.
+     * @param message The message will be part of the exception.
+     * @return The supplied object as convenient.
+     */
+    public static <T> List<T> requireNotEmpty( List<T> obj, String message )
+    {
+        if ( obj.isEmpty() )
+        {
+            throw new IllegalArgumentException( message );
+        }
+        return obj;
+    }
+
+    /**
+     * assert that the given {@code longValue} is greater than {@code 0}.
+     *
+     * @param longValue The instance which should be not {@code null} and has to be greater than {@code 0}.
+     * @param message   The message will be part of the exception.
+     * @return The supplied object as convenient.
+     */
+    public static Long requireGreaterThanZero( Long longValue, String message )
+    {
+        if ( longValue == null )
+        {
+            throw new IllegalArgumentException( message );
+        }
+
+        if ( longValue < 0 )
+        {
+            throw new IllegalArgumentException( message );
+        }
+        return longValue;
+    }
+
+    public static Long requireGreaterOrEqualZero( Long longValue, String message )
+    {
+        if ( longValue == null )
+        {
+            throw new IllegalArgumentException( message );
+        }
+
+        if ( longValue <= 0 )
+        {
+            throw new IllegalArgumentException( message );
+        }
+        return longValue;
+    }
+
+    public static void isTrue( boolean expression, String message, final long value )
+    {
+        if ( !expression )
+        {
+            throw new IllegalArgumentException( String.format( message, Long.valueOf( value ) ) );
+        }
+    }
+
+    public static void isTrue( boolean expression, String message, final Object... values )
+    {
+        if ( !expression )
+        {
+            throw new IllegalArgumentException( String.format( message, values ) );
+        }
+    }
+
+    public static Long greaterOrEqualToZero( Long currentValue, String message, final long value )
+    {
+        if ( currentValue == null )
+        {
+            throw new IllegalArgumentException( String.format( message, value ) );
+        }
+
+        if ( currentValue < 0 )
+        {
+            throw new IllegalArgumentException( String.format( message, value ) );
+        }
+        return currentValue;
+    }
+
+    public static Long requireGreaterThanZero( Long longValue, String message, final long value )
+    {
+        if ( longValue == null )
+        {
+            throw new IllegalArgumentException( String.format( message, value ) );
+        }
+
+        if ( longValue <= 0 )
+        {
+            throw new IllegalArgumentException( String.format( message, value ) );
+        }
+        return longValue;
+    }
+
+    /**
+     * assert that the given {@code integerValue} is greater than {@code 0}.
+     *
+     * @param integerValue The instance which should be not {@code null} and has to be greater than {@code 0}.
+     * @param message      The message will be part of the exception.
+     * @return The supplied object as convenient.
+     */
+    public static Integer requireGreaterThanZero( Integer integerValue, String message )
+    {
+        if ( integerValue == null )
+        {
+            throw new IllegalArgumentException( message );
+        }
+
+        if ( integerValue <= 0 )
+        {
+            throw new IllegalArgumentException( message );
+        }
+        return integerValue;
+    }
+
+    //    /**
+    //     * assert that the given {@code str} is not {@code null} and not {@code empty}.
+    //     *
+    //     * @param str     The str which should not be {@code null} and not be empty.
+    //     * @param message The message for the exception in case of {@code null}.
+    //     * @return The supplied object as convenient.
+    //     */
+    //    public static String requireNotEmpty(String str, String message)
+    //    {
+    //        requireNotNull( str, message );
+    //        if ( StringUtils.isBlank( str ) )
+    //        {
+    //            throw new IllegalArgumentException( message );
+    //        }
+    //        return str;
+    //    }
+
+
+    public static boolean isNotEmpty( String str )
+    {
+        return ( ( str != null ) && ( !str.isEmpty() ) );
+    }
+
+    public static boolean isNotBlank( final CharSequence cs )
+    {
+        return !isBlank( cs );
+    }
+
+    public static boolean isBlank( final CharSequence cs )
+    {
+        if ( cs == null || ( cs.length() ) == 0 )
+        {
+            return true;
+        }
+        for ( int i = 0; i < cs.length(); i++ )
+        {
+            if ( !Character.isWhitespace( cs.charAt( i ) ) )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static boolean notBlank( String str, String message )
+    {
+        for ( int i = 0; i < str.length(); i++ )
+        {
+            if ( !Character.isWhitespace( str.charAt( i ) ) )
+            {
+                return false;
+            }
+        }
+        throw new IllegalArgumentException( message );
+    }
+
+
+    public static boolean isBlank( String str, String message )
+    {
+        if ( str == null || str.trim().isEmpty() )
+        {
+            return true;
+        }
+        return true;
+    }
+
+    public static boolean isEmpty( final CharSequence cs )
+    {
+        return cs == null || cs.length() == 0;
+    }
+
+    public static boolean isDigits( final String str )
+    {
+        return isNumeric( str );
+    }
+
+    public static boolean isNumeric( final CharSequence cs )
+    {
+        if ( isEmpty( cs ) )
+        {
+            return false;
+        }
+        final int sz = cs.length();
+        for ( int i = 0; i < sz; i++ )
+        {
+            if ( !Character.isDigit( cs.charAt( i ) ) )
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+
+}
+
diff --git a/maven-utils/src/main/java/org/apache/maven/utils/StringUtils.java b/maven-utils/src/main/java/org/apache/maven/utils/StringUtils.java
new file mode 100644
index 0000000..9f29aaf
--- /dev/null
+++ b/maven-utils/src/main/java/org/apache/maven/utils/StringUtils.java
@@ -0,0 +1,61 @@
+package org.apache.maven.utils;
+
+/*
+ * 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 static org.apache.maven.utils.Precondition.isEmpty;
+
+/**
+ * @author Karl Heinz Marbaise
+ */
+public final class StringUtils
+{
+    public static final String EMPTY = "";
+    public static final int INDEX_NOT_FOUND = -1;
+    private StringUtils()
+    {
+        // intentionally empty.
+    }
+
+    /**
+     * @param str The string.
+     * @param separator The separator.
+     * @return The substring.
+     * TODO: Should be moved to maven-shared-utils.
+     */
+    public static String substringAfterLast( final String str, final String separator )
+    {
+        if ( isEmpty( str ) )
+        {
+            return str;
+        }
+        if ( isEmpty( separator ) )
+        {
+            return EMPTY;
+        }
+        final int pos = str.lastIndexOf( separator );
+        if ( pos == INDEX_NOT_FOUND || pos == str.length() - separator.length() )
+        {
+            return EMPTY;
+        }
+        return str.substring( pos + separator.length() );
+    }
+
+
+}
diff --git a/maven-utils/src/test/java/org/apache/maven/utils/PreconditionTest.java b/maven-utils/src/test/java/org/apache/maven/utils/PreconditionTest.java
new file mode 100644
index 0000000..18811c5
--- /dev/null
+++ b/maven-utils/src/test/java/org/apache/maven/utils/PreconditionTest.java
@@ -0,0 +1,34 @@
+package org.apache.maven.utils;
+
+/*
+ * 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 org.junit.jupiter.api.Test;
+
+import static org.apache.maven.utils.Precondition.notBlank;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+class PreconditionTest
+{
+    @Test
+    void first()
+    {
+        assertThatCode( () -> notBlank( "x", "Message" ) ).doesNotThrowAnyException();
+    }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 3e73b2f..2fe30ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,6 @@ under the License.
     <maven.compiler.target>1.8</maven.compiler.target>
     <classWorldsVersion>2.6.0</classWorldsVersion>
     <commonsCliVersion>1.4</commonsCliVersion>
-    <commonsLangVersion>3.8.1</commonsLangVersion>
     <junitVersion>4.12</junitVersion>
     <mockitoVersion>3.2.0</mockitoVersion>
     <plexusVersion>2.1.0</plexusVersion>
@@ -95,6 +94,7 @@ under the License.
     <module>maven-embedder</module>
     <module>maven-compat</module>
     <module>apache-maven</module>
+    <module>maven-utils</module>
   </modules>
 
   <scm>
@@ -232,6 +232,11 @@ under the License.
         <artifactId>maven-slf4j-provider</artifactId>
         <version>${project.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-utils</artifactId>
+        <version>${project.version}</version>
+      </dependency>
       <!--bootstrap-end-comment-->
       <!--  Plexus -->
       <dependency>
@@ -375,11 +380,6 @@ under the License.
         <version>${jxpathVersion}</version>
       </dependency>
       <dependency>
-        <groupId>org.apache.commons</groupId>
-        <artifactId>commons-lang3</artifactId>
-        <version>${commonsLangVersion}</version>
-      </dependency>
-      <dependency>
         <groupId>org.sonatype.plexus</groupId>
         <artifactId>plexus-sec-dispatcher</artifactId>
         <version>${securityDispatcherVersion}</version>
@@ -424,6 +424,18 @@ under the License.
         <version>2.2</version>
         <scope>test</scope>
       </dependency>
+      <dependency>
+        <groupId>org.assertj</groupId>
+        <artifactId>assertj-core</artifactId>
+        <version>3.14.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.junit</groupId>
+        <artifactId>junit-bom</artifactId>
+        <version>5.6.0-M1</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
     </dependencies>
     <!--bootstrap-start-comment-->
   </dependencyManagement>