Skip to content

Commit

Permalink
Replace org.apache.commons.lang3.Validate#notNull with java.util.Obje…
Browse files Browse the repository at this point in the history
…cts#requireNonNull
  • Loading branch information
rfscholte committed Jul 15, 2018
1 parent 6f41a82 commit 72dca39
Show file tree
Hide file tree
Showing 40 changed files with 122 additions and 142 deletions.
5 changes: 3 additions & 2 deletions Jenkinsfile
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions maven-builder-support/pom.xml
Expand Up @@ -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>
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand Down
Expand Up @@ -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;
Expand All @@ -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 );

Expand All @@ -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 )
{
Expand All @@ -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 )
{
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();

Expand All @@ -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;

Expand All @@ -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 )
{
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down
Expand Up @@ -19,7 +19,8 @@
* under the License.
*/

import org.apache.commons.lang3.Validate;
import java.util.Objects;

import org.apache.maven.project.MavenProject;

/**
Expand Down Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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() )
{
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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<>();

Expand All @@ -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<>();

Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -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>();

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) )
{
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) )
{
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 72dca39

Please sign in to comment.