Replace org.apache.commons.lang3.Validate#notNull with java.util.Objects#requireNonNull

This commit is contained in:
rfscholte 2018-07-15 10:35:40 +02:00
parent 6f41a82bb8
commit 72dca39807
40 changed files with 122 additions and 142 deletions

5
Jenkinsfile vendored
View File

@ -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

View File

@ -33,11 +33,4 @@ under the License.
<name>Maven Builder Support</name>
<description>Support for descriptor builders (model, setting, toolchains)</description>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -23,8 +23,7 @@
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

View File

@ -22,8 +22,7 @@
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

View File

@ -22,8 +22,8 @@
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 static RepositorySystemSession overlay( ArtifactRepository repository, Re
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 =

View File

@ -24,8 +24,8 @@
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<String, ?> 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 Metadata read( File input, Map<String, ?> options )
public Metadata read( Reader input, Map<String, ?> 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 Metadata read( Reader input, Map<String, ?> options )
public Metadata read( InputStream input, Map<String, ?> options )
throws IOException
{
Validate.notNull( input, "input cannot be null" );
Objects.requireNonNull( input, "input cannot be null" );
try ( final InputStream in = input )
{

View File

@ -26,6 +26,7 @@
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.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 ClassRealm getCoreRealm()
public ClassRealm createProjectRealm( Model model, List<Artifact> artifacts )
{
Validate.notNull( model, "model cannot be null" );
Objects.requireNonNull( model, "model cannot be null" );
ClassLoader parent = getMavenApiRealm();
@ -241,7 +241,7 @@ private static String getKey( Model model )
public ClassRealm createExtensionRealm( Plugin plugin, List<Artifact> artifacts )
{
Validate.notNull( plugin, "plugin cannot be null" );
Objects.requireNonNull( plugin, "plugin cannot be null" );
ClassLoader parent = PARENT_CLASSLOADER;
@ -259,7 +259,7 @@ private boolean isProvidedArtifact( Artifact artifact )
public ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List<String> parentImports,
Map<String, ClassLoader> foreignImports, List<Artifact> artifacts )
{
Validate.notNull( plugin, "plugin cannot be null" );
Objects.requireNonNull( plugin, "plugin cannot be null" );
if ( parent == null )
{

View File

@ -20,8 +20,8 @@
*/
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 )

View File

@ -19,7 +19,8 @@
* 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;
}

View File

@ -25,9 +25,9 @@
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 MavenExecutionRequest setProxies( List<Proxy> proxies )
@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 MavenExecutionRequest setServers( List<Server> servers )
@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 MavenExecutionRequest setMirrors( List<Mirror> mirrors )
@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 ProjectBuildingRequest getProjectBuildingRequest()
@Override
public MavenExecutionRequest addProfile( Profile profile )
{
Validate.notNull( profile, "profile cannot be null" );
Objects.requireNonNull( profile, "profile cannot be null" );
for ( Profile p : getProfiles() )
{

View File

@ -24,9 +24,9 @@
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 List<MavenProject> getSortedProjects()
public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive )
{
Validate.notNull( project, "project cannot be null" );
Objects.requireNonNull( project, "project cannot be null" );
Set<String> projectIds = new HashSet<>();
@ -117,7 +117,7 @@ private void getDownstreamProjects( String projectId, Set<String> projectIds, bo
public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive )
{
Validate.notNull( project, "project cannot be null" );
Objects.requireNonNull( project, "project cannot be null" );
Set<String> projectIds = new HashSet<>();

View File

@ -24,8 +24,8 @@
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<? extends MavenProject> whiteList )
{
this.projectDependencyGraph =
Validate.notNull( projectDependencyGraph, "projectDependencyGraph cannot be null" );
Objects.requireNonNull( projectDependencyGraph, "projectDependencyGraph cannot be null" );
this.whiteList = new IdentityHashMap<MavenProject, Object>();

View File

@ -23,9 +23,9 @@
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 CacheRecord get( Key key )
public CacheRecord put( Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor,
List<Artifact> artifacts )
{
Validate.notNull( extensionRealm, "extensionRealm cannot be null" );
Objects.requireNonNull( extensionRealm, "extensionRealm cannot be null" );
if ( cache.containsKey( key ) )
{

View File

@ -26,7 +26,6 @@
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 CacheRecord get( Key key )
public CacheRecord put( Key key, List<Artifact> pluginArtifacts )
{
Validate.notNull( pluginArtifacts, "pluginArtifacts cannot be null" );
Objects.requireNonNull( pluginArtifacts, "pluginArtifacts cannot be null" );
assertUniqueKey( key );
@ -173,7 +172,7 @@ protected void assertUniqueKey( Key key )
public CacheRecord put( Key key, PluginResolutionException exception )
{
Validate.notNull( exception, "exception cannot be null" );
Objects.requireNonNull( exception, "exception cannot be null" );
assertUniqueKey( key );

View File

@ -26,7 +26,6 @@
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 CacheRecord get( Key key )
public CacheRecord put( Key key, ClassRealm pluginRealm, List<Artifact> 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 ) )
{

View File

@ -19,7 +19,6 @@
* 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.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 @@ private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession
Map<String, ClassLoader> 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();

View File

@ -20,8 +20,8 @@
*/
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();
}

View File

@ -22,9 +22,9 @@
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 DefaultProjectBuildingRequest setRepositorySession( RepositorySystemSessi
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;
}

View File

@ -22,9 +22,9 @@
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 CacheRecord get( Key key )
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 ) )
{

View File

@ -29,7 +29,6 @@
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 CacheRecord get( Key key )
@Override
public CacheRecord put( Key key, Set<Artifact> projectArtifacts )
{
Validate.notNull( projectArtifacts, "projectArtifacts cannot be null" );
Objects.requireNonNull( projectArtifacts, "projectArtifacts cannot be null" );
assertUniqueKey( key );
@ -222,7 +221,7 @@ protected void assertUniqueKey( Key key )
@Override
public CacheRecord put( Key key, LifecycleExecutionException exception )
{
Validate.notNull( exception, "exception cannot be null" );
Objects.requireNonNull( exception, "exception cannot be null" );
assertUniqueKey( key );

View File

@ -24,11 +24,11 @@
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<String, ?> 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 PersistedToolchains read( File input, Map<String, ?> options )
public PersistedToolchains read( Reader input, Map<String, ?> 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 PersistedToolchains read( Reader input, Map<String, ?> options )
public PersistedToolchains read( InputStream input, Map<String, ?> options )
throws IOException
{
Validate.notNull( input, "input cannot be null" );
Objects.requireNonNull( input, "input cannot be null" );
try ( final InputStream in = input )
{

View File

@ -21,11 +21,11 @@
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() );
}

View File

@ -24,8 +24,8 @@
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 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 )

View File

@ -62,10 +62,6 @@ under the License.
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>

View File

@ -20,7 +20,6 @@
*/
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.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 @@ private ModelData readParentExternally( Model childModel, ModelBuildingRequest r
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

View File

@ -23,8 +23,8 @@
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 @@ public List<String> getModelIds()
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 @@ public Model getRawModel( String modelId )
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 @@ public List<Profile> getActivePomProfiles( String modelId )
public DefaultModelBuildingResult setActivePomProfiles( String modelId, List<Profile> 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 )
{

View File

@ -19,7 +19,8 @@
* 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()

View File

@ -25,8 +25,8 @@
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<String, ?> 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 Model read( File input, Map<String, ?> options )
public Model read( Reader input, Map<String, ?> 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 Model read( Reader input, Map<String, ?> options )
public Model read( InputStream input, Map<String, ?> options )
throws IOException
{
Validate.notNull( input, "input cannot be null" );
Objects.requireNonNull( input, "input cannot be null" );
try ( final XmlStreamReader in = ReaderFactory.newXmlReader( input ) )
{

View File

@ -25,8 +25,8 @@
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<String, Object> 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 void write( File output, Map<String, Object> options, Model model )
public void write( Writer output, Map<String, Object> 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 void write( Writer output, Map<String, Object> options, Model model )
public void write( OutputStream output, Map<String, Object> 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

View File

@ -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 @@
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<T extends ProfileActivator>
public AbstractProfileActivatorTest( Class<T> 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();
}

View File

@ -42,10 +42,6 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -24,9 +24,9 @@
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 )
{

View File

@ -82,10 +82,6 @@ under the License.
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.apache.maven.resolver</groupId>

View File

@ -21,6 +21,7 @@
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.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 @@ void setLogger( LoggerFactory loggerFactory )
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;
}

View File

@ -19,7 +19,6 @@
* 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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author Benjamin Bentmann
@ -121,20 +121,20 @@ void setLogger( LoggerFactory loggerFactory )
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;
}

View File

@ -19,7 +19,6 @@
* 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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author Benjamin Bentmann
@ -133,19 +133,19 @@ void setLogger( LoggerFactory loggerFactory )
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;
}

View File

@ -21,8 +21,8 @@
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;

View File

@ -65,10 +65,6 @@ under the License.
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-sec-dispatcher</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -24,8 +24,8 @@
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<String, ?> 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 Settings read( File input, Map<String, ?> options )
public Settings read( Reader input, Map<String, ?> 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 Settings read( Reader input, Map<String, ?> options )
public Settings read( InputStream input, Map<String, ?> options )
throws IOException
{
Validate.notNull( input, "input cannot be null" );
Objects.requireNonNull( input, "input cannot be null" );
try ( final InputStream in = input )
{

View File

@ -25,8 +25,8 @@
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<String, Object> 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 void write( File output, Map<String, Object> options, Settings settings )
public void write( Writer output, Map<String, Object> 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 void write( Writer output, Map<String, Object> options, Settings settings
public void write( OutputStream output, Map<String, Object> 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