From 72dca398070fb9eed1795c395ad8707bab9289f9 Mon Sep 17 00:00:00 2001 From: rfscholte Date: Sun, 15 Jul 2018 10:35:40 +0200 Subject: [PATCH] Replace org.apache.commons.lang3.Validate#notNull with java.util.Objects#requireNonNull --- Jenkinsfile | 5 +++-- maven-builder-support/pom.xml | 7 ------- .../org/apache/maven/building/FileSource.java | 5 ++--- .../java/org/apache/maven/building/UrlSource.java | 5 ++--- .../repository/LegacyLocalRepositoryManager.java | 4 ++-- .../metadata/io/DefaultMetadataReader.java | 8 ++++---- .../classrealm/DefaultClassRealmManager.java | 8 ++++---- .../internal/DefaultBeanConfigurator.java | 6 +++--- .../org/apache/maven/execution/BuildSummary.java | 5 +++-- .../execution/DefaultMavenExecutionRequest.java | 10 +++++----- .../graph/DefaultProjectDependencyGraph.java | 6 +++--- .../graph/FilteredProjectDependencyGraph.java | 4 ++-- .../maven/plugin/DefaultExtensionRealmCache.java | 4 ++-- .../maven/plugin/DefaultPluginArtifactsCache.java | 5 ++--- .../maven/plugin/DefaultPluginRealmCache.java | 5 ++--- .../internal/DefaultMavenPluginManager.java | 9 +++++---- .../project/DefaultModelBuildingListener.java | 9 +++++---- .../project/DefaultProjectBuildingRequest.java | 4 ++-- .../maven/project/DefaultProjectRealmCache.java | 4 ++-- .../artifact/DefaultProjectArtifactsCache.java | 5 ++--- .../toolchain/io/DefaultToolchainsReader.java | 8 ++++---- .../maven/project/harness/PomTestWrapper.java | 6 +++--- .../maven/cli/event/ExecutionEventLogger.java | 4 ++-- maven-model-builder/pom.xml | 4 ---- .../maven/model/building/DefaultModelBuilder.java | 9 +++++---- .../building/DefaultModelBuildingResult.java | 8 ++++---- .../building/ModelProblemCollectorRequest.java | 7 ++++--- .../apache/maven/model/io/DefaultModelReader.java | 8 ++++---- .../apache/maven/model/io/DefaultModelWriter.java | 14 +++++++------- .../activation/AbstractProfileActivatorTest.java | 5 +++-- maven-model/pom.xml | 4 ---- .../org/apache/maven/model/merge/ModelMerger.java | 4 ++-- maven-resolver-provider/pom.xml | 4 ---- .../internal/DefaultArtifactDescriptorReader.java | 15 ++++++++------- .../internal/DefaultVersionRangeResolver.java | 8 ++++---- .../internal/DefaultVersionResolver.java | 8 ++++---- .../repository/internal/RelocatedArtifact.java | 4 ++-- maven-settings-builder/pom.xml | 4 ---- .../maven/settings/io/DefaultSettingsReader.java | 8 ++++---- .../maven/settings/io/DefaultSettingsWriter.java | 14 +++++++------- 40 files changed, 122 insertions(+), 142 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b775de8588..93ba46ad6c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,8 @@ def tests try { -node(jenkinsEnv.labelForOS(buildOs)) { +def osNode = jenkinsEnv.labelForOS(buildOs) +node(jenkinsEnv.nodeSelection(osNode)) { dir('build') { stage('Checkout') { checkout scm @@ -73,7 +74,7 @@ for (String os in runITsOses) { String stageId = "${os}-jdk${jdk}" String stageLabel = "Run ITs ${os.capitalize()} Java ${jdk}" runITsTasks[stageId] = { - node(osLabel) { + node(jenkinsEnv.nodeSelection(osLabel)) { stage("${stageLabel}") { // on Windows, need a short path or we hit 256 character limit for paths // using EXECUTOR_NUMBER guarantees that concurrent builds on same agent diff --git a/maven-builder-support/pom.xml b/maven-builder-support/pom.xml index 9bcec7cc4a..2b46f7dba9 100644 --- a/maven-builder-support/pom.xml +++ b/maven-builder-support/pom.xml @@ -33,11 +33,4 @@ under the License. Maven Builder Support Support for descriptor builders (model, setting, toolchains) - - - org.apache.commons - commons-lang3 - - - diff --git a/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java b/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java index afba119cf5..66e6441049 100644 --- a/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java +++ b/maven-builder-support/src/main/java/org/apache/maven/building/FileSource.java @@ -23,8 +23,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; - -import org.apache.commons.lang3.Validate; +import java.util.Objects; /** * Wraps an ordinary {@link File} as a source. @@ -43,7 +42,7 @@ public class FileSource */ public FileSource( File file ) { - this.file = Validate.notNull( file, "file cannot be null" ).getAbsoluteFile(); + this.file = Objects.requireNonNull( file, "file cannot be null" ).getAbsoluteFile(); } @Override diff --git a/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java b/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java index beabece443..772091fcdc 100644 --- a/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java +++ b/maven-builder-support/src/main/java/org/apache/maven/building/UrlSource.java @@ -22,8 +22,7 @@ package org.apache.maven.building; import java.io.IOException; import java.io.InputStream; import java.net.URL; - -import org.apache.commons.lang3.Validate; +import java.util.Objects; /** * Wraps an ordinary {@link URL} as a source. @@ -43,7 +42,7 @@ public class UrlSource */ public UrlSource( URL url ) { - this.url = Validate.notNull( url, "url cannot be null" ); + this.url = Objects.requireNonNull( url, "url cannot be null" ); } @Override diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java index bc6336447c..634b63cefb 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java @@ -22,8 +22,8 @@ package org.apache.maven.artifact.repository; import java.io.File; import java.util.Collections; import java.util.List; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; @@ -89,7 +89,7 @@ public class LegacyLocalRepositoryManager private LegacyLocalRepositoryManager( ArtifactRepository delegate ) { - this.delegate = Validate.notNull( delegate, "delegate cannot be null" ); + this.delegate = Objects.requireNonNull( delegate, "delegate cannot be null" ); ArtifactRepositoryLayout layout = delegate.getLayout(); repo = diff --git a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java index 51a2849b12..0139ab319d 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/repository/metadata/io/DefaultMetadataReader.java @@ -24,8 +24,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.metadata.Metadata; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.codehaus.plexus.component.annotations.Component; @@ -45,7 +45,7 @@ public class DefaultMetadataReader public Metadata read( File input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); Metadata metadata = read( ReaderFactory.newXmlReader( input ), options ); @@ -55,7 +55,7 @@ public class DefaultMetadataReader public Metadata read( Reader input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final Reader in = input ) { @@ -70,7 +70,7 @@ public class DefaultMetadataReader public Metadata read( InputStream input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final InputStream in = input ) { diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java index 6ce192588b..a4835fdd47 100644 --- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java +++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Random; import java.util.Set; import java.util.TreeMap; @@ -34,7 +35,6 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.classrealm.ClassRealmRequest.RealmType; import org.apache.maven.extension.internal.CoreExportsProvider; @@ -227,7 +227,7 @@ public class DefaultClassRealmManager public ClassRealm createProjectRealm( Model model, List artifacts ) { - Validate.notNull( model, "model cannot be null" ); + Objects.requireNonNull( model, "model cannot be null" ); ClassLoader parent = getMavenApiRealm(); @@ -241,7 +241,7 @@ public class DefaultClassRealmManager public ClassRealm createExtensionRealm( Plugin plugin, List artifacts ) { - Validate.notNull( plugin, "plugin cannot be null" ); + Objects.requireNonNull( plugin, "plugin cannot be null" ); ClassLoader parent = PARENT_CLASSLOADER; @@ -259,7 +259,7 @@ public class DefaultClassRealmManager public ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List parentImports, Map foreignImports, List artifacts ) { - Validate.notNull( plugin, "plugin cannot be null" ); + Objects.requireNonNull( plugin, "plugin cannot be null" ); if ( parent == null ) { diff --git a/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java b/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java index 1b3c71a1da..00c79b794e 100644 --- a/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java +++ b/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java @@ -20,8 +20,8 @@ package org.apache.maven.configuration.internal; */ import java.io.File; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.configuration.BeanConfigurationException; import org.apache.maven.configuration.BeanConfigurationPathTranslator; import org.apache.maven.configuration.BeanConfigurationRequest; @@ -54,8 +54,8 @@ public class DefaultBeanConfigurator public void configureBean( BeanConfigurationRequest request ) throws BeanConfigurationException { - Validate.notNull( request, "request cannot be null" ); - Validate.notNull( request.getBean(), "request.bean cannot be null" ); + Objects.requireNonNull( request, "request cannot be null" ); + Objects.requireNonNull( request.getBean(), "request.bean cannot be null" ); Object configuration = request.getConfiguration(); if ( configuration == null ) diff --git a/maven-core/src/main/java/org/apache/maven/execution/BuildSummary.java b/maven-core/src/main/java/org/apache/maven/execution/BuildSummary.java index 0825bf4ad5..79599b5db8 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/BuildSummary.java +++ b/maven-core/src/main/java/org/apache/maven/execution/BuildSummary.java @@ -19,7 +19,8 @@ package org.apache.maven.execution; * under the License. */ -import org.apache.commons.lang3.Validate; +import java.util.Objects; + import org.apache.maven.project.MavenProject; /** @@ -48,7 +49,7 @@ public abstract class BuildSummary */ protected BuildSummary( MavenProject project, long time ) { - this.project = Validate.notNull( project, "project cannot be null" ); + this.project = Objects.requireNonNull( project, "project cannot be null" ); // TODO Validate for < 0? this.time = time; } diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java index fe558cd338..4a039eb3e1 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java @@ -25,9 +25,9 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Properties; -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.eventspy.internal.EventSpyDispatcher; import org.apache.maven.model.Profile; @@ -778,7 +778,7 @@ public class DefaultMavenExecutionRequest @Override public MavenExecutionRequest addProxy( Proxy proxy ) { - Validate.notNull( proxy, "proxy cannot be null" ); + Objects.requireNonNull( proxy, "proxy cannot be null" ); for ( Proxy p : getProxies() ) { @@ -821,7 +821,7 @@ public class DefaultMavenExecutionRequest @Override public MavenExecutionRequest addServer( Server server ) { - Validate.notNull( server, "server cannot be null" ); + Objects.requireNonNull( server, "server cannot be null" ); for ( Server p : getServers() ) { @@ -864,7 +864,7 @@ public class DefaultMavenExecutionRequest @Override public MavenExecutionRequest addMirror( Mirror mirror ) { - Validate.notNull( mirror, "mirror cannot be null" ); + Objects.requireNonNull( mirror, "mirror cannot be null" ); for ( Mirror p : getMirrors() ) { @@ -1111,7 +1111,7 @@ public class DefaultMavenExecutionRequest @Override public MavenExecutionRequest addProfile( Profile profile ) { - Validate.notNull( profile, "profile cannot be null" ); + Objects.requireNonNull( profile, "profile cannot be null" ); for ( Profile p : getProfiles() ) { diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java index 73cadf63fa..e0067f1fe4 100644 --- a/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java +++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultProjectDependencyGraph.java @@ -24,9 +24,9 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; -import org.apache.commons.lang3.Validate; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; @@ -95,7 +95,7 @@ public class DefaultProjectDependencyGraph public List getDownstreamProjects( MavenProject project, boolean transitive ) { - Validate.notNull( project, "project cannot be null" ); + Objects.requireNonNull( project, "project cannot be null" ); Set projectIds = new HashSet<>(); @@ -117,7 +117,7 @@ public class DefaultProjectDependencyGraph public List getUpstreamProjects( MavenProject project, boolean transitive ) { - Validate.notNull( project, "project cannot be null" ); + Objects.requireNonNull( project, "project cannot be null" ); Set projectIds = new HashSet<>(); diff --git a/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java b/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java index 795e666612..5097e4a39e 100644 --- a/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java +++ b/maven-core/src/main/java/org/apache/maven/graph/FilteredProjectDependencyGraph.java @@ -24,8 +24,8 @@ import java.util.Collection; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.MavenProject; @@ -54,7 +54,7 @@ class FilteredProjectDependencyGraph Collection whiteList ) { this.projectDependencyGraph = - Validate.notNull( projectDependencyGraph, "projectDependencyGraph cannot be null" ); + Objects.requireNonNull( projectDependencyGraph, "projectDependencyGraph cannot be null" ); this.whiteList = new IdentityHashMap(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java index 4391f87494..6ce63ebbf1 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java @@ -23,9 +23,9 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.Artifact; import org.apache.maven.project.ExtensionDescriptor; import org.apache.maven.project.MavenProject; @@ -126,7 +126,7 @@ public class DefaultExtensionRealmCache public CacheRecord put( Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor, List artifacts ) { - Validate.notNull( extensionRealm, "extensionRealm cannot be null" ); + Objects.requireNonNull( extensionRealm, "extensionRealm cannot be null" ); if ( cache.containsKey( key ) ) { diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java index c625f37a69..ee11c4c898 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java @@ -26,7 +26,6 @@ import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang3.Validate; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; @@ -151,7 +150,7 @@ public class DefaultPluginArtifactsCache public CacheRecord put( Key key, List pluginArtifacts ) { - Validate.notNull( pluginArtifacts, "pluginArtifacts cannot be null" ); + Objects.requireNonNull( pluginArtifacts, "pluginArtifacts cannot be null" ); assertUniqueKey( key ); @@ -173,7 +172,7 @@ public class DefaultPluginArtifactsCache public CacheRecord put( Key key, PluginResolutionException exception ) { - Validate.notNull( exception, "exception cannot be null" ); + Objects.requireNonNull( exception, "exception cannot be null" ); assertUniqueKey( key ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java index b82a2b5447..7862b40def 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java @@ -26,7 +26,6 @@ import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang3.Validate; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; @@ -159,8 +158,8 @@ public class DefaultPluginRealmCache public CacheRecord put( Key key, ClassRealm pluginRealm, List pluginArtifacts ) { - Validate.notNull( pluginRealm, "pluginRealm cannot be null" ); - Validate.notNull( pluginArtifacts, "pluginArtifacts cannot be null" ); + Objects.requireNonNull( pluginRealm, "pluginRealm cannot be null" ); + Objects.requireNonNull( pluginArtifacts, "pluginArtifacts cannot be null" ); if ( cache.containsKey( key ) ) { diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 34b3b17bf6..cec6f120db 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -19,7 +19,6 @@ package org.apache.maven.plugin.internal; * under the License. */ -import org.apache.commons.lang3.Validate; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.classrealm.ClassRealmManager; @@ -104,6 +103,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.jar.JarFile; import java.util.zip.ZipEntry; @@ -385,10 +385,11 @@ public class DefaultMavenPluginManager Map foreignImports, DependencyFilter filter ) throws PluginResolutionException, PluginContainerException { - Plugin plugin = Validate.notNull( pluginDescriptor.getPlugin(), "pluginDescriptor.plugin cannot be null" ); + Plugin plugin = + Objects.requireNonNull( pluginDescriptor.getPlugin(), "pluginDescriptor.plugin cannot be null" ); - Artifact pluginArtifact = - Validate.notNull( pluginDescriptor.getPluginArtifact(), "pluginDescriptor.pluginArtifact cannot be null" ); + Artifact pluginArtifact = Objects.requireNonNull( pluginDescriptor.getPluginArtifact(), + "pluginDescriptor.pluginArtifact cannot be null" ); MavenProject project = session.getCurrentProject(); diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java index 91a875bcd6..95317b2f79 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java @@ -20,8 +20,8 @@ package org.apache.maven.project; */ import java.util.List; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.model.building.AbstractModelBuildingListener; @@ -55,10 +55,11 @@ public class DefaultModelBuildingListener public DefaultModelBuildingListener( MavenProject project, ProjectBuildingHelper projectBuildingHelper, ProjectBuildingRequest projectBuildingRequest ) { - this.project = Validate.notNull( project, "project cannot be null" ); - this.projectBuildingHelper = Validate.notNull( projectBuildingHelper, "projectBuildingHelper cannot be null" ); + this.project = Objects.requireNonNull( project, "project cannot be null" ); + this.projectBuildingHelper = + Objects.requireNonNull( projectBuildingHelper, "projectBuildingHelper cannot be null" ); this.projectBuildingRequest = - Validate.notNull( projectBuildingRequest, "projectBuildingRequest cannot be null" ); + Objects.requireNonNull( projectBuildingRequest, "projectBuildingRequest cannot be null" ); this.remoteRepositories = projectBuildingRequest.getRemoteRepositories(); this.pluginRepositories = projectBuildingRequest.getPluginArtifactRepositories(); } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java index 0451a306fc..811f2b8352 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java @@ -22,9 +22,9 @@ package org.apache.maven.project; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.Properties; -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Profile; import org.apache.maven.model.building.ModelBuildingRequest; @@ -335,7 +335,7 @@ public class DefaultProjectBuildingRequest public DefaultProjectBuildingRequest setRepositoryMerging( RepositoryMerging repositoryMerging ) { - this.repositoryMerging = Validate.notNull( repositoryMerging, "repositoryMerging cannot be null" ); + this.repositoryMerging = Objects.requireNonNull( repositoryMerging, "repositoryMerging cannot be null" ); return this; } diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java index a14e624af8..987f861a18 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectRealmCache.java @@ -22,9 +22,9 @@ package org.apache.maven.project; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang3.Validate; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.component.annotations.Component; @@ -102,7 +102,7 @@ public class DefaultProjectRealmCache public CacheRecord put( Key key, ClassRealm projectRealm, DependencyFilter extensionArtifactFilter ) { - Validate.notNull( projectRealm, "projectRealm cannot be null" ); + Objects.requireNonNull( projectRealm, "projectRealm cannot be null" ); if ( cache.containsKey( key ) ) { diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java index 3d9d32daa0..1f6ab2a72f 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/DefaultProjectArtifactsCache.java @@ -29,7 +29,6 @@ import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang3.Validate; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.lifecycle.LifecycleExecutionException; @@ -199,7 +198,7 @@ public class DefaultProjectArtifactsCache @Override public CacheRecord put( Key key, Set projectArtifacts ) { - Validate.notNull( projectArtifacts, "projectArtifacts cannot be null" ); + Objects.requireNonNull( projectArtifacts, "projectArtifacts cannot be null" ); assertUniqueKey( key ); @@ -222,7 +221,7 @@ public class DefaultProjectArtifactsCache @Override public CacheRecord put( Key key, LifecycleExecutionException exception ) { - Validate.notNull( exception, "exception cannot be null" ); + Objects.requireNonNull( exception, "exception cannot be null" ); assertUniqueKey( key ); diff --git a/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java b/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java index 86a178495d..93dcca5f94 100644 --- a/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java +++ b/maven-core/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java @@ -24,11 +24,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; +import java.util.Objects; import javax.inject.Named; import javax.inject.Singleton; -import org.apache.commons.lang3.Validate; import org.apache.maven.toolchain.model.PersistedToolchains; import org.apache.maven.toolchain.model.io.xpp3.MavenToolchainsXpp3Reader; import org.codehaus.plexus.util.ReaderFactory; @@ -50,7 +50,7 @@ public class DefaultToolchainsReader public PersistedToolchains read( File input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); return read( ReaderFactory.newXmlReader( input ), options ); } @@ -59,7 +59,7 @@ public class DefaultToolchainsReader public PersistedToolchains read( Reader input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final Reader in = input ) { @@ -75,7 +75,7 @@ public class DefaultToolchainsReader public PersistedToolchains read( InputStream input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final InputStream in = input ) { diff --git a/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java b/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java index f91b9831bb..f6275d8210 100644 --- a/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java +++ b/maven-core/src/test/java/org/apache/maven/project/harness/PomTestWrapper.java @@ -21,11 +21,11 @@ package org.apache.maven.project.harness; import java.io.File; import java.util.Iterator; +import java.util.Objects; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathNotFoundException; import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl; -import org.apache.commons.lang3.Validate; import org.apache.maven.project.MavenProject; public class PomTestWrapper @@ -44,14 +44,14 @@ public class PomTestWrapper public PomTestWrapper( File pomFile, MavenProject mavenProject ) { - this.mavenProject = Validate.notNull( mavenProject, "mavenProject cannot be null" ); + this.mavenProject = Objects.requireNonNull( mavenProject, "mavenProject cannot be null" ); this.pomFile = pomFile; context = JXPathContext.newContext( mavenProject.getModel() ); } public PomTestWrapper( MavenProject mavenProject ) { - this.mavenProject = Validate.notNull( mavenProject, "mavenProject cannot be null" ); + this.mavenProject = Objects.requireNonNull( mavenProject, "mavenProject cannot be null" ); context = JXPathContext.newContext( mavenProject.getModel() ); } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java index 51d00b7850..00c9164e33 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java @@ -24,8 +24,8 @@ import static org.apache.maven.cli.CLIReportingUtils.formatTimestamp; import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; import java.util.List; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.execution.AbstractExecutionListener; import org.apache.maven.execution.BuildFailure; import org.apache.maven.execution.BuildSuccess; @@ -66,7 +66,7 @@ public class ExecutionEventLogger // TODO should we deprecate? public ExecutionEventLogger( Logger logger ) { - this.logger = Validate.notNull( logger, "logger cannot be null" ); + this.logger = Objects.requireNonNull( logger, "logger cannot be null" ); } private static String chars( char c, int count ) diff --git a/maven-model-builder/pom.xml b/maven-model-builder/pom.xml index 5b3c11d125..149f081511 100644 --- a/maven-model-builder/pom.xml +++ b/maven-model-builder/pom.xml @@ -62,10 +62,6 @@ under the License. com.google.guava guava - - org.apache.commons - commons-lang3 - org.eclipse.sisu org.eclipse.sisu.plexus diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java index 44ee334c30..e68ff3000e 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java @@ -20,7 +20,6 @@ package org.apache.maven.model.building; */ -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; @@ -74,6 +73,7 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Properties; import static org.apache.maven.model.building.Result.error; @@ -1042,9 +1042,10 @@ public class DefaultModelBuilder String version = parent.getVersion(); ModelResolver modelResolver = request.getModelResolver(); - - Validate.notNull( modelResolver, "request.modelResolver cannot be null (parent POM %s and POM %s)", - ModelProblemUtils.toId( groupId, artifactId, version ), ModelProblemUtils.toSourceHint( childModel ) ); + Objects.requireNonNull( modelResolver, + String.format( "request.modelResolver cannot be null (parent POM %s and POM %s)", + ModelProblemUtils.toId( groupId, artifactId, version ), + ModelProblemUtils.toSourceHint( childModel ) ) ); ModelSource modelSource; try diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java index 7c14063468..13b7714360 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingResult.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.model.Model; import org.apache.maven.model.Profile; @@ -80,7 +80,7 @@ class DefaultModelBuildingResult public DefaultModelBuildingResult addModelId( String modelId ) { // Intentionally notNull because Super POM may not contain a modelId - Validate.notNull( modelId, "modelId cannot null" ); + Objects.requireNonNull( modelId, "modelId cannot null" ); modelIds.add( modelId ); @@ -102,7 +102,7 @@ class DefaultModelBuildingResult public DefaultModelBuildingResult setRawModel( String modelId, Model rawModel ) { // Intentionally notNull because Super POM may not contain a modelId - Validate.notNull( modelId, "modelId cannot null" ); + Objects.requireNonNull( modelId, "modelId cannot null" ); rawModels.put( modelId, rawModel ); @@ -118,7 +118,7 @@ class DefaultModelBuildingResult public DefaultModelBuildingResult setActivePomProfiles( String modelId, List activeProfiles ) { // Intentionally notNull because Super POM may not contain a modelId - Validate.notNull( modelId, "modelId cannot null" ); + Objects.requireNonNull( modelId, "modelId cannot null" ); if ( activeProfiles != null ) { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java index a3cfd0de02..8edab3c01d 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelProblemCollectorRequest.java @@ -19,7 +19,8 @@ package org.apache.maven.model.building; * under the License. */ -import org.apache.commons.lang3.Validate; +import java.util.Objects; + import org.apache.maven.model.InputLocation; import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelProblem.Version; @@ -45,8 +46,8 @@ public final class ModelProblemCollectorRequest */ public ModelProblemCollectorRequest( Severity severity, Version version ) { - this.severity = Validate.notNull( severity, "severity cannot be null" ); - this.version = Validate.notNull( version, "version cannot be null" ); + this.severity = Objects.requireNonNull( severity, "severity cannot be null" ); + this.version = Objects.requireNonNull( version, "version cannot be null" ); } public Severity getSeverity() diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java index e07ac3b98a..cc1e2fcbd9 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelReader.java @@ -25,8 +25,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.model.InputSource; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; @@ -50,7 +50,7 @@ public class DefaultModelReader public Model read( File input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); Model model = read( new FileInputStream( input ), options ); @@ -63,7 +63,7 @@ public class DefaultModelReader public Model read( Reader input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final Reader in = input ) { @@ -75,7 +75,7 @@ public class DefaultModelReader public Model read( InputStream input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final XmlStreamReader in = ReaderFactory.newXmlReader( input ) ) { diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java index c899efab0a..d0da9a3fa8 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/io/DefaultModelWriter.java @@ -25,8 +25,8 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.codehaus.plexus.component.annotations.Component; @@ -46,8 +46,8 @@ public class DefaultModelWriter public void write( File output, Map options, Model model ) throws IOException { - Validate.notNull( output, "output cannot be null" ); - Validate.notNull( model, "model cannot be null" ); + Objects.requireNonNull( output, "output cannot be null" ); + Objects.requireNonNull( model, "model cannot be null" ); output.getParentFile().mkdirs(); @@ -58,8 +58,8 @@ public class DefaultModelWriter public void write( Writer output, Map options, Model model ) throws IOException { - Validate.notNull( output, "output cannot be null" ); - Validate.notNull( model, "model cannot be null" ); + Objects.requireNonNull( output, "output cannot be null" ); + Objects.requireNonNull( model, "model cannot be null" ); try ( final Writer out = output ) { @@ -71,8 +71,8 @@ public class DefaultModelWriter public void write( OutputStream output, Map options, Model model ) throws IOException { - Validate.notNull( output, "output cannot be null" ); - Validate.notNull( model, "model cannot be null" ); + Objects.requireNonNull( output, "output cannot be null" ); + Objects.requireNonNull( model, "model cannot be null" ); String encoding = model.getModelEncoding(); // TODO Use StringUtils here diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java index a77efdc979..edc8373416 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/profile/activation/AbstractProfileActivatorTest.java @@ -1,5 +1,7 @@ package org.apache.maven.model.profile.activation; +import java.util.Objects; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,7 +23,6 @@ package org.apache.maven.model.profile.activation; import java.util.Properties; -import org.apache.commons.lang3.Validate; import org.apache.maven.model.Profile; import org.apache.maven.model.building.SimpleProblemCollector; import org.apache.maven.model.profile.DefaultProfileActivationContext; @@ -46,7 +47,7 @@ public abstract class AbstractProfileActivatorTest public AbstractProfileActivatorTest( Class activatorClass ) { - this.activatorClass = Validate.notNull( activatorClass, "activatorClass cannot be null" );; + this.activatorClass = Objects.requireNonNull( activatorClass, "activatorClass cannot be null" );; roleHint = activatorClass.getAnnotation( Component.class ).hint(); } diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 7829c73fd1..757e2fb3c2 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -42,10 +42,6 @@ under the License. org.codehaus.plexus plexus-utils - - org.apache.commons - commons-lang3 - diff --git a/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java b/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java index fbc056e929..e10ce0f2dd 100644 --- a/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java +++ b/maven-model/src/main/java/org/apache/maven/model/merge/ModelMerger.java @@ -24,9 +24,9 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Properties; -import org.apache.commons.lang3.Validate; import org.apache.maven.model.Activation; import org.apache.maven.model.Build; import org.apache.maven.model.BuildBase; @@ -105,7 +105,7 @@ public class ModelMerger */ public void merge( Model target, Model source, boolean sourceDominant, Map hints ) { - Validate.notNull( target, "target cannot be null" ); + Objects.requireNonNull( target, "target cannot be null" ); if ( source == null ) { diff --git a/maven-resolver-provider/pom.xml b/maven-resolver-provider/pom.xml index 09db30d068..13868a2e10 100644 --- a/maven-resolver-provider/pom.xml +++ b/maven-resolver-provider/pom.xml @@ -82,10 +82,6 @@ under the License. - - org.apache.commons - commons-lang3 - org.apache.maven.resolver diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java index 7ccdc056e3..748c7713bf 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java @@ -21,6 +21,7 @@ package org.apache.maven.repository.internal; import java.util.LinkedHashSet; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.Set; @@ -28,7 +29,6 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.apache.commons.lang3.Validate; import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Relocation; @@ -145,41 +145,42 @@ public class DefaultArtifactDescriptorReader public DefaultArtifactDescriptorReader setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager ) { - this.remoteRepositoryManager = Validate.notNull( remoteRepositoryManager, + this.remoteRepositoryManager = Objects.requireNonNull( remoteRepositoryManager, "remoteRepositoryManager cannot be null" ); return this; } public DefaultArtifactDescriptorReader setVersionResolver( VersionResolver versionResolver ) { - this.versionResolver = Validate.notNull( versionResolver, "versionResolver cannot be null" ); + this.versionResolver = Objects.requireNonNull( versionResolver, "versionResolver cannot be null" ); return this; } /** @since 3.2.2 */ public DefaultArtifactDescriptorReader setVersionRangeResolver( VersionRangeResolver versionRangeResolver ) { - this.versionRangeResolver = Validate.notNull( versionRangeResolver, "versionRangeResolver cannot be null" ); + this.versionRangeResolver = + Objects.requireNonNull( versionRangeResolver, "versionRangeResolver cannot be null" ); return this; } public DefaultArtifactDescriptorReader setArtifactResolver( ArtifactResolver artifactResolver ) { - this.artifactResolver = Validate.notNull( artifactResolver, "artifactResolver cannot be null" ); + this.artifactResolver = Objects.requireNonNull( artifactResolver, "artifactResolver cannot be null" ); return this; } public DefaultArtifactDescriptorReader setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ) { - this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher, + this.repositoryEventDispatcher = Objects.requireNonNull( repositoryEventDispatcher, "repositoryEventDispatcher cannot be null" ); return this; } public DefaultArtifactDescriptorReader setModelBuilder( ModelBuilder modelBuilder ) { - this.modelBuilder = Validate.notNull( modelBuilder, "modelBuilder cannot be null" ); + this.modelBuilder = Objects.requireNonNull( modelBuilder, "modelBuilder cannot be null" ); return this; } diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java index 7a8ad9fb80..2f92e1609e 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionRangeResolver.java @@ -19,7 +19,6 @@ package org.apache.maven.repository.internal; * under the License. */ -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; import org.eclipse.aether.RepositoryEvent; @@ -63,6 +62,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * @author Benjamin Bentmann @@ -121,20 +121,20 @@ public class DefaultVersionRangeResolver public DefaultVersionRangeResolver setMetadataResolver( MetadataResolver metadataResolver ) { - this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" ); + this.metadataResolver = Objects.requireNonNull( metadataResolver, "metadataResolver cannot be null" ); return this; } public DefaultVersionRangeResolver setSyncContextFactory( SyncContextFactory syncContextFactory ) { - this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" ); + this.syncContextFactory = Objects.requireNonNull( syncContextFactory, "syncContextFactory cannot be null" ); return this; } public DefaultVersionRangeResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ) { - this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher, + this.repositoryEventDispatcher = Objects.requireNonNull( repositoryEventDispatcher, "repositoryEventDispatcher cannot be null" ); return this; } diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java index ef7f0cfb07..1896005ed1 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionResolver.java @@ -19,7 +19,6 @@ package org.apache.maven.repository.internal; * under the License. */ -import org.apache.commons.lang3.Validate; import org.apache.maven.artifact.repository.metadata.Snapshot; import org.apache.maven.artifact.repository.metadata.SnapshotVersion; import org.apache.maven.artifact.repository.metadata.Versioning; @@ -69,6 +68,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * @author Benjamin Bentmann @@ -133,19 +133,19 @@ public class DefaultVersionResolver public DefaultVersionResolver setMetadataResolver( MetadataResolver metadataResolver ) { - this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" ); + this.metadataResolver = Objects.requireNonNull( metadataResolver, "metadataResolver cannot be null" ); return this; } public DefaultVersionResolver setSyncContextFactory( SyncContextFactory syncContextFactory ) { - this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" ); + this.syncContextFactory = Objects.requireNonNull( syncContextFactory, "syncContextFactory cannot be null" ); return this; } public DefaultVersionResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher ) { - this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher, + this.repositoryEventDispatcher = Objects.requireNonNull( repositoryEventDispatcher, "repositoryEventDispatcher cannot be null" ); return this; } diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java index 7c2d0ce9ea..2e277f0e4c 100644 --- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java +++ b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/RelocatedArtifact.java @@ -21,8 +21,8 @@ package org.apache.maven.repository.internal; import java.io.File; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.eclipse.aether.artifact.AbstractArtifact; import org.eclipse.aether.artifact.Artifact; @@ -43,7 +43,7 @@ final class RelocatedArtifact RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version ) { - this.artifact = Validate.notNull( artifact, "artifact cannot be null" ); + this.artifact = Objects.requireNonNull( artifact, "artifact cannot be null" ); // TODO Use StringUtils here this.groupId = ( groupId != null && groupId.length() > 0 ) ? groupId : null; this.artifactId = ( artifactId != null && artifactId.length() > 0 ) ? artifactId : null; diff --git a/maven-settings-builder/pom.xml b/maven-settings-builder/pom.xml index 3d8bdcaebb..5f08129a72 100644 --- a/maven-settings-builder/pom.xml +++ b/maven-settings-builder/pom.xml @@ -65,10 +65,6 @@ under the License. org.sonatype.plexus plexus-sec-dispatcher - - org.apache.commons - commons-lang3 - diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java index 897f7424c3..fa9561371d 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java @@ -24,8 +24,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.settings.Settings; import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader; import org.codehaus.plexus.component.annotations.Component; @@ -46,7 +46,7 @@ public class DefaultSettingsReader public Settings read( File input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); Settings settings = read( ReaderFactory.newXmlReader( input ), options ); @@ -57,7 +57,7 @@ public class DefaultSettingsReader public Settings read( Reader input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final Reader in = input ) { @@ -73,7 +73,7 @@ public class DefaultSettingsReader public Settings read( InputStream input, Map options ) throws IOException { - Validate.notNull( input, "input cannot be null" ); + Objects.requireNonNull( input, "input cannot be null" ); try ( final InputStream in = input ) { diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java index 19d8b9ba1a..96af1a340a 100644 --- a/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java +++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsWriter.java @@ -25,8 +25,8 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.Map; +import java.util.Objects; -import org.apache.commons.lang3.Validate; import org.apache.maven.settings.Settings; import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; import org.codehaus.plexus.component.annotations.Component; @@ -46,8 +46,8 @@ public class DefaultSettingsWriter public void write( File output, Map options, Settings settings ) throws IOException { - Validate.notNull( output, "output cannot be null" ); - Validate.notNull( settings, "settings cannot be null" ); + Objects.requireNonNull( output, "output cannot be null" ); + Objects.requireNonNull( settings, "settings cannot be null" ); output.getParentFile().mkdirs(); @@ -58,8 +58,8 @@ public class DefaultSettingsWriter public void write( Writer output, Map options, Settings settings ) throws IOException { - Validate.notNull( output, "output cannot be null" ); - Validate.notNull( settings, "settings cannot be null" ); + Objects.requireNonNull( output, "output cannot be null" ); + Objects.requireNonNull( settings, "settings cannot be null" ); try ( final Writer out = output ) { @@ -71,8 +71,8 @@ public class DefaultSettingsWriter public void write( OutputStream output, Map options, Settings settings ) throws IOException { - Validate.notNull( output, "output cannot be null" ); - Validate.notNull( settings, "settings cannot be null" ); + Objects.requireNonNull( output, "output cannot be null" ); + Objects.requireNonNull( settings, "settings cannot be null" ); String encoding = settings.getModelEncoding(); // TODO Use StringUtils here