mirror of https://github.com/apache/maven.git
[MNG-5649] Use Commons Lang's Validate to intercept invalid input
Use wherever possible Validate with consistent messages and exceptions.
This commit is contained in:
parent
b9cc9c3652
commit
618e62dd33
|
@ -82,6 +82,10 @@ under the License.
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.aether</groupId>
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Relocation;
|
||||
|
@ -150,62 +151,41 @@ public class DefaultArtifactDescriptorReader
|
|||
|
||||
public DefaultArtifactDescriptorReader setRemoteRepositoryManager( RemoteRepositoryManager remoteRepositoryManager )
|
||||
{
|
||||
if ( remoteRepositoryManager == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "remote repository manager has not been specified" );
|
||||
}
|
||||
this.remoteRepositoryManager = remoteRepositoryManager;
|
||||
this.remoteRepositoryManager = Validate.notNull( remoteRepositoryManager,
|
||||
"remoteRepositoryManager cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultArtifactDescriptorReader setVersionResolver( VersionResolver versionResolver )
|
||||
{
|
||||
if ( versionResolver == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "version resolver has not been specified" );
|
||||
}
|
||||
this.versionResolver = versionResolver;
|
||||
this.versionResolver = Validate.notNull( versionResolver, "versionResolver cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @since 3.2.2 */
|
||||
public DefaultArtifactDescriptorReader setVersionRangeResolver( VersionRangeResolver versionRangeResolver )
|
||||
{
|
||||
if ( versionRangeResolver == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "version range resolver has not been specified" );
|
||||
}
|
||||
this.versionRangeResolver = versionRangeResolver;
|
||||
this.versionRangeResolver = Validate.notNull( versionRangeResolver, "versionRangeResolver cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultArtifactDescriptorReader setArtifactResolver( ArtifactResolver artifactResolver )
|
||||
{
|
||||
if ( artifactResolver == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "artifact resolver has not been specified" );
|
||||
}
|
||||
this.artifactResolver = artifactResolver;
|
||||
this.artifactResolver = Validate.notNull( artifactResolver, "artifactResolver cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultArtifactDescriptorReader setRepositoryEventDispatcher( RepositoryEventDispatcher red )
|
||||
public DefaultArtifactDescriptorReader setRepositoryEventDispatcher(
|
||||
RepositoryEventDispatcher repositoryEventDispatcher )
|
||||
{
|
||||
if ( red == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "repository event dispatcher has not been specified" );
|
||||
}
|
||||
this.repositoryEventDispatcher = red;
|
||||
this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
|
||||
"repositoryEventDispatcher cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultArtifactDescriptorReader setModelBuilder( ModelBuilder modelBuilder )
|
||||
{
|
||||
if ( modelBuilder == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "model builder has not been specified" );
|
||||
}
|
||||
this.modelBuilder = modelBuilder;
|
||||
this.modelBuilder = Validate.notNull( modelBuilder, "modelBuilder cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ 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.codehaus.plexus.component.annotations.Component;
|
||||
|
@ -124,31 +125,21 @@ public class DefaultVersionRangeResolver
|
|||
|
||||
public DefaultVersionRangeResolver setMetadataResolver( MetadataResolver metadataResolver )
|
||||
{
|
||||
if ( metadataResolver == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "metadata resolver has not been specified" );
|
||||
}
|
||||
this.metadataResolver = metadataResolver;
|
||||
this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultVersionRangeResolver setSyncContextFactory( SyncContextFactory syncContextFactory )
|
||||
{
|
||||
if ( syncContextFactory == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "sync context factory has not been specified" );
|
||||
}
|
||||
this.syncContextFactory = syncContextFactory;
|
||||
this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultVersionRangeResolver setRepositoryEventDispatcher( RepositoryEventDispatcher red )
|
||||
public DefaultVersionRangeResolver setRepositoryEventDispatcher(
|
||||
RepositoryEventDispatcher repositoryEventDispatcher )
|
||||
{
|
||||
if ( red == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "repository event dispatcher has not been specified" );
|
||||
}
|
||||
this.repositoryEventDispatcher = red;
|
||||
this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
|
||||
"repositoryEventDispatcher cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ 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;
|
||||
|
@ -136,31 +137,20 @@ public class DefaultVersionResolver
|
|||
|
||||
public DefaultVersionResolver setMetadataResolver( MetadataResolver metadataResolver )
|
||||
{
|
||||
if ( metadataResolver == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "metadata resolver has not been specified" );
|
||||
}
|
||||
this.metadataResolver = metadataResolver;
|
||||
this.metadataResolver = Validate.notNull( metadataResolver, "metadataResolver cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultVersionResolver setSyncContextFactory( SyncContextFactory syncContextFactory )
|
||||
{
|
||||
if ( syncContextFactory == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "sync context factory has not been specified" );
|
||||
}
|
||||
this.syncContextFactory = syncContextFactory;
|
||||
this.syncContextFactory = Validate.notNull( syncContextFactory, "syncContextFactory cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultVersionResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher )
|
||||
{
|
||||
if ( repositoryEventDispatcher == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "repository event dispatcher has not been specified" );
|
||||
}
|
||||
this.repositoryEventDispatcher = repositoryEventDispatcher;
|
||||
this.repositoryEventDispatcher = Validate.notNull( repositoryEventDispatcher,
|
||||
"repositoryEventDispatcher cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven.repository.internal;
|
|||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.eclipse.aether.artifact.AbstractArtifact;
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
|
||||
|
@ -42,11 +43,8 @@ final class RelocatedArtifact
|
|||
|
||||
public RelocatedArtifact( Artifact artifact, String groupId, String artifactId, String version )
|
||||
{
|
||||
if ( artifact == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no artifact specified" );
|
||||
}
|
||||
this.artifact = artifact;
|
||||
this.artifact = Validate.notNull( 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;
|
||||
this.version = ( version != null && version.length() > 0 ) ? version : null;
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
|
||||
public final class ArtifactUtils
|
||||
|
@ -50,10 +51,7 @@ public final class ArtifactUtils
|
|||
|
||||
public static String toSnapshotVersion( String version )
|
||||
{
|
||||
if ( version == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "version: null" );
|
||||
}
|
||||
Validate.notBlank( version, "version can neither be null, empty nor blank" );
|
||||
|
||||
Matcher m = Artifact.VERSION_FILE_PATTERN.matcher( version );
|
||||
if ( m.matches() )
|
||||
|
@ -73,14 +71,9 @@ public final class ArtifactUtils
|
|||
|
||||
public static String versionlessKey( String groupId, String artifactId )
|
||||
{
|
||||
if ( groupId == null )
|
||||
{
|
||||
throw new NullPointerException( "groupId is null" );
|
||||
}
|
||||
if ( artifactId == null )
|
||||
{
|
||||
throw new NullPointerException( "artifactId is null" );
|
||||
}
|
||||
Validate.notBlank( groupId, "groupId can neither be null, empty nor blank" );
|
||||
Validate.notBlank( artifactId, "artifactId can neither be null, empty nor blank" );
|
||||
|
||||
return groupId + ":" + artifactId;
|
||||
}
|
||||
|
||||
|
@ -91,18 +84,9 @@ public final class ArtifactUtils
|
|||
|
||||
public static String key( String groupId, String artifactId, String version )
|
||||
{
|
||||
if ( groupId == null )
|
||||
{
|
||||
throw new NullPointerException( "groupId is null" );
|
||||
}
|
||||
if ( artifactId == null )
|
||||
{
|
||||
throw new NullPointerException( "artifactId is null" );
|
||||
}
|
||||
if ( version == null )
|
||||
{
|
||||
throw new NullPointerException( "version is null" );
|
||||
}
|
||||
Validate.notBlank( groupId, "groupId can neither be null, empty nor blank" );
|
||||
Validate.notBlank( artifactId, "artifactId can neither be null, empty nor blank" );
|
||||
Validate.notBlank( version, "version can neither be null, empty nor blank" );
|
||||
|
||||
return groupId + ":" + artifactId + ":" + version;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ 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>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.io.FileInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link File} as a source.
|
||||
*
|
||||
|
@ -41,11 +43,7 @@ public class FileSource
|
|||
*/
|
||||
public FileSource( File file )
|
||||
{
|
||||
if ( file == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no file specified" );
|
||||
}
|
||||
this.file = file.getAbsoluteFile();
|
||||
this.file = Validate.notNull( file, "file cannot be null" ).getAbsoluteFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
/**
|
||||
* Wraps an ordinary {@link URL} as a source.
|
||||
*
|
||||
|
@ -41,11 +43,7 @@ public class UrlSource
|
|||
*/
|
||||
public UrlSource( URL url )
|
||||
{
|
||||
if ( url == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no url specified" );
|
||||
}
|
||||
this.url = url;
|
||||
this.url = Validate.notNull( url, "url cannot be null" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,9 +39,9 @@ public class FileSourceTest
|
|||
new FileSource( null );
|
||||
fail( "Should fail, since you must specify a file" );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch ( NullPointerException e )
|
||||
{
|
||||
assertEquals( "no file specified", e.getMessage() );
|
||||
assertEquals( "file cannot be null", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@ public class UrlSourceTest
|
|||
new UrlSource( null );
|
||||
fail( "Should fail, since you must specify a url" );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch ( NullPointerException e )
|
||||
{
|
||||
assertEquals( "no url specified", e.getMessage() );
|
||||
assertEquals( "url cannot be null", e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,10 @@
|
|||
<groupId>org.sonatype.plexus</groupId>
|
||||
<artifactId>plexus-sec-dispatcher</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-jxpath</groupId>
|
||||
<artifactId>commons-jxpath</artifactId>
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.File;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
@ -88,11 +89,7 @@ public class LegacyLocalRepositoryManager
|
|||
|
||||
private LegacyLocalRepositoryManager( ArtifactRepository delegate )
|
||||
{
|
||||
if ( delegate == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "local repository delegate missing" );
|
||||
}
|
||||
this.delegate = delegate;
|
||||
this.delegate = Validate.notNull( delegate, "delegate cannot be null" );
|
||||
|
||||
ArtifactRepositoryLayout layout = delegate.getLayout();
|
||||
repo =
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.InputStream;
|
|||
import java.io.Reader;
|
||||
import java.util.Map;
|
||||
|
||||
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,10 +46,7 @@ public class DefaultMetadataReader
|
|||
public Metadata read( File input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input file missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
Metadata metadata = read( ReaderFactory.newXmlReader( input ), options );
|
||||
|
||||
|
@ -58,10 +56,7 @@ public class DefaultMetadataReader
|
|||
public Metadata read( Reader input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input reader missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -81,10 +76,7 @@ public class DefaultMetadataReader
|
|||
public Metadata read( InputStream input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input stream missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ 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;
|
||||
|
@ -101,7 +102,7 @@ public class DefaultClassRealmManager
|
|||
Map<String, ClassLoader> foreignImports = exports.get().getExportedPackages();
|
||||
|
||||
this.mavenApiRealm =
|
||||
createRealm( API_REALMID, RealmType.Core, null /* parent */, null /* parentImports */,
|
||||
createRealm( API_REALMID, RealmType.Core, null /* parent */, null /* parentImports */,
|
||||
foreignImports, null /* artifacts */ );
|
||||
|
||||
this.providedArtifacts = exports.get().getExportedArtifacts();
|
||||
|
@ -226,10 +227,7 @@ public class DefaultClassRealmManager
|
|||
|
||||
public ClassRealm createProjectRealm( Model model, List<Artifact> artifacts )
|
||||
{
|
||||
if ( model == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "model missing" );
|
||||
}
|
||||
Validate.notNull( model, "model cannot be null" );
|
||||
|
||||
ClassLoader parent = getMavenApiRealm();
|
||||
|
||||
|
@ -243,10 +241,7 @@ public class DefaultClassRealmManager
|
|||
|
||||
public ClassRealm createExtensionRealm( Plugin plugin, List<Artifact> artifacts )
|
||||
{
|
||||
if ( plugin == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "extension plugin missing" );
|
||||
}
|
||||
Validate.notNull( plugin, "plugin cannot be null" );
|
||||
|
||||
ClassLoader parent = PARENT_CLASSLOADER;
|
||||
|
||||
|
@ -264,10 +259,7 @@ public class DefaultClassRealmManager
|
|||
public ClassRealm createPluginRealm( Plugin plugin, ClassLoader parent, List<String> parentImports,
|
||||
Map<String, ClassLoader> foreignImports, List<Artifact> artifacts )
|
||||
{
|
||||
if ( plugin == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "plugin missing" );
|
||||
}
|
||||
Validate.notNull( plugin, "plugin cannot be null" );
|
||||
|
||||
if ( parent == null )
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.configuration;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
|
@ -120,14 +121,8 @@ public class DefaultBeanConfigurationRequest
|
|||
|
||||
private Plugin findPlugin( Model model, String groupId, String artifactId )
|
||||
{
|
||||
if ( StringUtils.isEmpty( groupId ) )
|
||||
{
|
||||
throw new IllegalArgumentException( "group id for plugin has not been specified" );
|
||||
}
|
||||
if ( StringUtils.isEmpty( artifactId ) )
|
||||
{
|
||||
throw new IllegalArgumentException( "artifact id for plugin has not been specified" );
|
||||
}
|
||||
Validate.notBlank( groupId, "groupId can neither be null, empty nor blank" );
|
||||
Validate.notBlank( artifactId, "artifactId can neither be null, empty nor blank" );
|
||||
|
||||
if ( model != null )
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.maven.configuration.internal;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.configuration.BeanConfigurationException;
|
||||
import org.apache.maven.configuration.BeanConfigurationPathTranslator;
|
||||
import org.apache.maven.configuration.BeanConfigurationRequest;
|
||||
|
@ -53,15 +54,8 @@ public class DefaultBeanConfigurator
|
|||
public void configureBean( BeanConfigurationRequest request )
|
||||
throws BeanConfigurationException
|
||||
{
|
||||
if ( request == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "bean configuration request not specified" );
|
||||
}
|
||||
|
||||
if ( request.getBean() == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "bean to be configured not specified" );
|
||||
}
|
||||
Validate.notNull( request, "request cannot be null" );
|
||||
Validate.notNull( request.getBean(), "request.bean cannot be null" );
|
||||
|
||||
Object configuration = request.getConfiguration();
|
||||
if ( configuration == null )
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.execution;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
|
@ -47,11 +48,8 @@ public abstract class BuildSummary
|
|||
*/
|
||||
protected BuildSummary( MavenProject project, long time )
|
||||
{
|
||||
if ( project == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "project missing" );
|
||||
}
|
||||
this.project = project;
|
||||
this.project = Validate.notNull( project, "project cannot be null" );
|
||||
// TODO Validate for < 0?
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
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;
|
||||
|
@ -57,7 +58,7 @@ public class DefaultMavenExecutionRequest
|
|||
private ArtifactRepository localRepository;
|
||||
|
||||
private EventSpyDispatcher eventSpyDispatcher;
|
||||
|
||||
|
||||
private File localRepositoryPath;
|
||||
|
||||
private boolean offline = false;
|
||||
|
@ -149,7 +150,7 @@ public class DefaultMavenExecutionRequest
|
|||
private int degreeOfConcurrency = 1;
|
||||
|
||||
private String builderId = "singlethreaded";
|
||||
|
||||
|
||||
private Map<String, List<ToolchainModel>> toolchains;
|
||||
|
||||
/**
|
||||
|
@ -162,7 +163,7 @@ public class DefaultMavenExecutionRequest
|
|||
private boolean useLegacyLocalRepositoryManager = false;
|
||||
|
||||
private Map<String, Object> data;
|
||||
|
||||
|
||||
public DefaultMavenExecutionRequest()
|
||||
{
|
||||
}
|
||||
|
@ -779,10 +780,7 @@ public class DefaultMavenExecutionRequest
|
|||
@Override
|
||||
public MavenExecutionRequest addProxy( Proxy proxy )
|
||||
{
|
||||
if ( proxy == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "proxy missing" );
|
||||
}
|
||||
Validate.notNull( proxy, "proxy cannot be null" );
|
||||
|
||||
for ( Proxy p : getProxies() )
|
||||
{
|
||||
|
@ -825,10 +823,7 @@ public class DefaultMavenExecutionRequest
|
|||
@Override
|
||||
public MavenExecutionRequest addServer( Server server )
|
||||
{
|
||||
if ( server == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "server missing" );
|
||||
}
|
||||
Validate.notNull( server, "server cannot be null" );
|
||||
|
||||
for ( Server p : getServers() )
|
||||
{
|
||||
|
@ -871,10 +866,7 @@ public class DefaultMavenExecutionRequest
|
|||
@Override
|
||||
public MavenExecutionRequest addMirror( Mirror mirror )
|
||||
{
|
||||
if ( mirror == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "mirror missing" );
|
||||
}
|
||||
Validate.notNull( mirror, "mirror cannot be null" );
|
||||
|
||||
for ( Mirror p : getMirrors() )
|
||||
{
|
||||
|
@ -1030,13 +1022,13 @@ public class DefaultMavenExecutionRequest
|
|||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getGlobalToolchainsFile()
|
||||
{
|
||||
return globalToolchainsFile;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MavenExecutionRequest setGlobalToolchainsFile( File globalToolchainsFile )
|
||||
{
|
||||
|
@ -1121,10 +1113,7 @@ public class DefaultMavenExecutionRequest
|
|||
@Override
|
||||
public MavenExecutionRequest addProfile( Profile profile )
|
||||
{
|
||||
if ( profile == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "profile missing" );
|
||||
}
|
||||
Validate.notNull( profile, "profile cannot be null" );
|
||||
|
||||
for ( Profile p : getProfiles() )
|
||||
{
|
||||
|
@ -1243,7 +1232,7 @@ public class DefaultMavenExecutionRequest
|
|||
{
|
||||
return builderId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, List<ToolchainModel>> getToolchains()
|
||||
{
|
||||
|
@ -1272,7 +1261,7 @@ public class DefaultMavenExecutionRequest
|
|||
{
|
||||
return multiModuleProjectDirectory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MavenExecutionRequest setEventSpyDispatcher( EventSpyDispatcher eventSpyDispatcher )
|
||||
{
|
||||
|
@ -1285,7 +1274,7 @@ public class DefaultMavenExecutionRequest
|
|||
{
|
||||
return eventSpyDispatcher;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getData()
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ public class ReactorManager
|
|||
|
||||
if ( pluginContext == null )
|
||||
{
|
||||
pluginContext = new HashMap();
|
||||
pluginContext = new HashMap<>();
|
||||
pluginContextsByKey.put( plugin.getPluginLookupKey(), pluginContext );
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
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;
|
||||
|
@ -62,10 +63,7 @@ public class DefaultProjectDependencyGraph
|
|||
|
||||
public List<MavenProject> getDownstreamProjects( MavenProject project, boolean transitive )
|
||||
{
|
||||
if ( project == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "project missing" );
|
||||
}
|
||||
Validate.notNull( project, "project cannot be null" );
|
||||
|
||||
Set<String> projectIds = new HashSet<>();
|
||||
|
||||
|
@ -87,10 +85,7 @@ public class DefaultProjectDependencyGraph
|
|||
|
||||
public List<MavenProject> getUpstreamProjects( MavenProject project, boolean transitive )
|
||||
{
|
||||
if ( project == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "project missing" );
|
||||
}
|
||||
Validate.notNull( project, "project cannot be null" );
|
||||
|
||||
Set<String> projectIds = new HashSet<>();
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.IdentityHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.execution.ProjectDependencyGraph;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
|
@ -52,12 +53,8 @@ class FilteredProjectDependencyGraph
|
|||
public FilteredProjectDependencyGraph( ProjectDependencyGraph projectDependencyGraph,
|
||||
Collection<? extends MavenProject> whiteList )
|
||||
{
|
||||
if ( projectDependencyGraph == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "project dependency graph missing" );
|
||||
}
|
||||
|
||||
this.projectDependencyGraph = projectDependencyGraph;
|
||||
this.projectDependencyGraph =
|
||||
Validate.notNull( projectDependencyGraph, "projectDependencyGraph cannot be null" );
|
||||
|
||||
this.whiteList = new IdentityHashMap<MavenProject, Object>();
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
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;
|
||||
|
@ -123,10 +124,7 @@ public class DefaultExtensionRealmCache
|
|||
public CacheRecord put( Key key, ClassRealm extensionRealm, ExtensionDescriptor extensionDescriptor,
|
||||
List<Artifact> artifacts )
|
||||
{
|
||||
if ( extensionRealm == null )
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Validate.notNull( extensionRealm, "extensionRealm cannot be null" );
|
||||
|
||||
if ( cache.containsKey( key ) )
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -156,10 +157,7 @@ public class DefaultPluginArtifactsCache
|
|||
|
||||
public CacheRecord put( Key key, List<Artifact> pluginArtifacts )
|
||||
{
|
||||
if ( pluginArtifacts == null )
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Validate.notNull( pluginArtifacts, "pluginArtifacts cannot be null" );
|
||||
|
||||
assertUniqueKey( key );
|
||||
|
||||
|
@ -181,10 +179,7 @@ public class DefaultPluginArtifactsCache
|
|||
|
||||
public CacheRecord put( Key key, PluginResolutionException exception )
|
||||
{
|
||||
if ( exception == null )
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Validate.notNull( exception, "exception cannot be null" );
|
||||
|
||||
assertUniqueKey( key );
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
@ -162,10 +163,8 @@ public class DefaultPluginRealmCache
|
|||
|
||||
public CacheRecord put( Key key, ClassRealm pluginRealm, List<Artifact> pluginArtifacts )
|
||||
{
|
||||
if ( pluginRealm == null || pluginArtifacts == null )
|
||||
{
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
Validate.notNull( pluginRealm, "pluginRealm cannot be null" );
|
||||
Validate.notNull( pluginArtifacts, "pluginArtifacts cannot be null" );
|
||||
|
||||
if ( cache.containsKey( key ) )
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ 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;
|
||||
|
@ -382,19 +383,10 @@ public class DefaultMavenPluginManager
|
|||
Map<String, ClassLoader> foreignImports, DependencyFilter filter )
|
||||
throws PluginResolutionException, PluginContainerException
|
||||
{
|
||||
Plugin plugin = pluginDescriptor.getPlugin();
|
||||
Plugin plugin = Validate.notNull( pluginDescriptor.getPlugin(), "pluginDescriptor.plugin cannot be null" );
|
||||
|
||||
if ( plugin == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "incomplete plugin descriptor, plugin missing" );
|
||||
}
|
||||
|
||||
Artifact pluginArtifact = pluginDescriptor.getPluginArtifact();
|
||||
|
||||
if ( pluginArtifact == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "incomplete plugin descriptor, plugin artifact missing" );
|
||||
}
|
||||
Artifact pluginArtifact =
|
||||
Validate.notNull( pluginDescriptor.getPluginArtifact(), "pluginDescriptor.pluginArtifact cannot be null" );
|
||||
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.maven.project;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
@ -54,23 +55,10 @@ public class DefaultModelBuildingListener
|
|||
public DefaultModelBuildingListener( MavenProject project, ProjectBuildingHelper projectBuildingHelper,
|
||||
ProjectBuildingRequest projectBuildingRequest )
|
||||
{
|
||||
if ( project == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "project missing" );
|
||||
}
|
||||
this.project = project;
|
||||
|
||||
if ( projectBuildingHelper == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "project building helper missing" );
|
||||
}
|
||||
this.projectBuildingHelper = projectBuildingHelper;
|
||||
|
||||
if ( projectBuildingRequest == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "project building request missing" );
|
||||
}
|
||||
this.projectBuildingRequest = projectBuildingRequest;
|
||||
this.project = Validate.notNull( project, "project cannot be null" );
|
||||
this.projectBuildingHelper = Validate.notNull( projectBuildingHelper, "projectBuildingHelper cannot be null" );
|
||||
this.projectBuildingRequest =
|
||||
Validate.notNull( projectBuildingRequest, "projectBuildingRequest cannot be null" );
|
||||
this.remoteRepositories = projectBuildingRequest.getRemoteRepositories();
|
||||
this.pluginRepositories = projectBuildingRequest.getPluginArtifactRepositories();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
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;
|
||||
|
@ -323,11 +324,7 @@ public class DefaultProjectBuildingRequest
|
|||
|
||||
public DefaultProjectBuildingRequest setRepositoryMerging( RepositoryMerging repositoryMerging )
|
||||
{
|
||||
if ( repositoryMerging == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "repository merge mode not specified" );
|
||||
}
|
||||
this.repositoryMerging = repositoryMerging;
|
||||
this.repositoryMerging = Validate.notNull( repositoryMerging, "repositoryMerging cannot be null" );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
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;
|
||||
|
@ -99,10 +100,7 @@ public class DefaultProjectRealmCache
|
|||
|
||||
public CacheRecord put( Key key, ClassRealm projectRealm, DependencyFilter extensionArtifactFilter )
|
||||
{
|
||||
if ( projectRealm == null )
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Validate.notNull( projectRealm, "projectRealm cannot be null" );
|
||||
|
||||
if ( cache.containsKey( key ) )
|
||||
{
|
||||
|
|
|
@ -141,12 +141,10 @@ public class ArtifactTransferEvent
|
|||
{
|
||||
switch ( requestType )
|
||||
{
|
||||
|
||||
case REQUEST_PUT:
|
||||
break;
|
||||
case REQUEST_GET:
|
||||
break;
|
||||
|
||||
default :
|
||||
throw new IllegalArgumentException( "Illegal request type: " + requestType );
|
||||
}
|
||||
|
@ -169,7 +167,6 @@ public class ArtifactTransferEvent
|
|||
{
|
||||
switch ( eventType )
|
||||
{
|
||||
|
||||
case TRANSFER_INITIATED:
|
||||
break;
|
||||
case TRANSFER_STARTED:
|
||||
|
|
|
@ -19,11 +19,12 @@ package org.apache.maven.rtinfo.internal;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.rtinfo.RuntimeInformation;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.eclipse.aether.util.version.GenericVersionScheme;
|
||||
import org.eclipse.aether.version.InvalidVersionSpecificationException;
|
||||
import org.eclipse.aether.version.Version;
|
||||
|
@ -99,14 +100,7 @@ public class DefaultRuntimeInformation
|
|||
{
|
||||
VersionScheme versionScheme = new GenericVersionScheme();
|
||||
|
||||
if ( versionRange == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Version range must not be null" );
|
||||
}
|
||||
if ( StringUtils.isBlank( versionRange ) )
|
||||
{
|
||||
throw new IllegalArgumentException( "Version range must not be empty" );
|
||||
}
|
||||
Validate.notBlank( versionRange, "versionRange can neither be null, empty nor blank" );
|
||||
|
||||
VersionConstraint constraint;
|
||||
try
|
||||
|
@ -122,10 +116,7 @@ public class DefaultRuntimeInformation
|
|||
try
|
||||
{
|
||||
String mavenVersion = getMavenVersion();
|
||||
if ( mavenVersion.length() <= 0 )
|
||||
{
|
||||
throw new IllegalStateException( "Could not determine current Maven version" );
|
||||
}
|
||||
Validate.validState( StringUtils.isNotEmpty( mavenVersion ), "Could not determine current Maven version" );
|
||||
|
||||
current = versionScheme.parseVersion( mavenVersion );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
|||
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.IOUtil;
|
||||
|
@ -50,10 +51,7 @@ public class DefaultToolchainsReader
|
|||
public PersistedToolchains read( File input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input file missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
return read( ReaderFactory.newXmlReader( input ), options );
|
||||
}
|
||||
|
@ -62,10 +60,7 @@ public class DefaultToolchainsReader
|
|||
public PersistedToolchains read( Reader input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input reader missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -86,10 +81,7 @@ public class DefaultToolchainsReader
|
|||
public PersistedToolchains read( InputStream input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input stream missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Iterator;
|
|||
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
|
||||
|
@ -43,22 +44,14 @@ public class PomTestWrapper
|
|||
|
||||
public PomTestWrapper( File pomFile, MavenProject mavenProject )
|
||||
{
|
||||
if ( mavenProject == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "mavenProject: null" );
|
||||
}
|
||||
this.mavenProject = mavenProject;
|
||||
this.mavenProject = Validate.notNull( mavenProject, "mavenProject cannot be null" );
|
||||
this.pomFile = pomFile;
|
||||
context = JXPathContext.newContext( mavenProject.getModel() );
|
||||
}
|
||||
|
||||
public PomTestWrapper( MavenProject mavenProject )
|
||||
{
|
||||
if ( mavenProject == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "mavenProject: null" );
|
||||
}
|
||||
this.mavenProject = mavenProject;
|
||||
this.mavenProject = Validate.notNull( mavenProject, "mavenProject cannot be null" );
|
||||
context = JXPathContext.newContext( mavenProject.getModel() );
|
||||
}
|
||||
|
||||
|
@ -81,10 +74,7 @@ public class PomTestWrapper
|
|||
public int containerCountForUri( String uri )
|
||||
throws IOException
|
||||
{
|
||||
if ( uri == null || uri.trim().equals( "" ) )
|
||||
{
|
||||
throw new IllegalArgumentException( "uri: null or empty" );
|
||||
}
|
||||
Validate.notEmpty( uri, "uri can neither be null nor empty " );
|
||||
ModelDataSource source = new DefaultModelDataSource();
|
||||
source.init( domainModel.getModelProperties(), null );
|
||||
return source.queryFor( uri ).size();
|
||||
|
|
|
@ -72,7 +72,7 @@ public class DefaultRuntimeInformationTest
|
|||
rtInfo.isMavenVersion( null );
|
||||
fail( "Bad version range wasn't rejected" );
|
||||
}
|
||||
catch ( IllegalArgumentException e )
|
||||
catch ( NullPointerException e )
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
|
|
|
@ -89,6 +89,10 @@
|
|||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven.cli.event;
|
|||
import static org.apache.maven.cli.CLIReportingUtils.formatDuration;
|
||||
import static org.apache.maven.cli.CLIReportingUtils.formatTimestamp;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.execution.AbstractExecutionListener;
|
||||
import org.apache.maven.execution.BuildFailure;
|
||||
import org.apache.maven.execution.BuildSuccess;
|
||||
|
@ -58,12 +59,7 @@ public class ExecutionEventLogger
|
|||
// TODO should we deprecate?
|
||||
public ExecutionEventLogger( Logger logger )
|
||||
{
|
||||
if ( logger == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "logger missing" );
|
||||
}
|
||||
|
||||
this.logger = logger;
|
||||
this.logger = Validate.notNull( logger, "logger cannot be null" );
|
||||
}
|
||||
|
||||
private static String chars( char c, int count )
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
<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>
|
||||
|
|
|
@ -20,6 +20,7 @@ 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;
|
||||
|
@ -486,7 +487,7 @@ public class DefaultModelBuilder
|
|||
{
|
||||
final ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( validationLevel )
|
||||
.setLocationTracking( locationTracking );
|
||||
final DefaultModelProblemCollector collector =
|
||||
final DefaultModelProblemCollector collector =
|
||||
new DefaultModelProblemCollector( new DefaultModelBuildingResult() );
|
||||
try
|
||||
{
|
||||
|
@ -512,7 +513,7 @@ public class DefaultModelBuilder
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException( "neither model source nor input file are specified" );
|
||||
throw new NullPointerException( "neither pomFile nor modelSource can be null" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -985,12 +986,8 @@ public class DefaultModelBuilder
|
|||
|
||||
ModelResolver modelResolver = request.getModelResolver();
|
||||
|
||||
if ( modelResolver == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no model resolver provided, cannot resolve parent POM "
|
||||
+ ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM "
|
||||
+ ModelProblemUtils.toSourceHint( childModel ) );
|
||||
}
|
||||
Validate.notNull( modelResolver, "request.modelResolver cannot be null (parent POM %s and POM %s)",
|
||||
ModelProblemUtils.toId( groupId, artifactId, version ), ModelProblemUtils.toSourceHint( childModel ) );
|
||||
|
||||
ModelSource modelSource;
|
||||
try
|
||||
|
@ -1159,9 +1156,11 @@ public class DefaultModelBuilder
|
|||
{
|
||||
if ( workspaceResolver == null && modelResolver == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no model resolver provided, cannot resolve import POM "
|
||||
+ ModelProblemUtils.toId( groupId, artifactId, version ) + " for POM "
|
||||
+ ModelProblemUtils.toSourceHint( model ) );
|
||||
throw new NullPointerException( String.format(
|
||||
"request.workspaceModelResolver and request.modelResolver cannot be null"
|
||||
+ " (parent POM %s and POM %s)",
|
||||
ModelProblemUtils.toId( groupId, artifactId, version ),
|
||||
ModelProblemUtils.toSourceHint( model ) ) );
|
||||
}
|
||||
|
||||
Model importModel = null;
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
|
@ -78,10 +79,8 @@ class DefaultModelBuildingResult
|
|||
|
||||
public DefaultModelBuildingResult addModelId( String modelId )
|
||||
{
|
||||
if ( modelId == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no model identifier specified" );
|
||||
}
|
||||
// Intentionally notNull because Super POM may not contain a modelId
|
||||
Validate.notNull( modelId, "modelId cannot null" );
|
||||
|
||||
modelIds.add( modelId );
|
||||
|
||||
|
@ -102,10 +101,8 @@ class DefaultModelBuildingResult
|
|||
|
||||
public DefaultModelBuildingResult setRawModel( String modelId, Model rawModel )
|
||||
{
|
||||
if ( modelId == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no model identifier specified" );
|
||||
}
|
||||
// Intentionally notNull because Super POM may not contain a modelId
|
||||
Validate.notNull( modelId, "modelId cannot null" );
|
||||
|
||||
rawModels.put( modelId, rawModel );
|
||||
|
||||
|
@ -120,10 +117,8 @@ class DefaultModelBuildingResult
|
|||
|
||||
public DefaultModelBuildingResult setActivePomProfiles( String modelId, List<Profile> activeProfiles )
|
||||
{
|
||||
if ( modelId == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "no model identifier specified" );
|
||||
}
|
||||
// Intentionally notNull because Super POM may not contain a modelId
|
||||
Validate.notNull( modelId, "modelId cannot null" );
|
||||
|
||||
if ( activeProfiles != null )
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.model.building;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.maven.model.InputLocation;
|
||||
import org.apache.maven.model.building.ModelProblem.Severity;
|
||||
import org.apache.maven.model.building.ModelProblem.Version;
|
||||
|
@ -44,16 +45,8 @@ public final class ModelProblemCollectorRequest
|
|||
*/
|
||||
public ModelProblemCollectorRequest( Severity severity, Version version )
|
||||
{
|
||||
this.severity = severity;
|
||||
this.version = version;
|
||||
if ( severity == null )
|
||||
{
|
||||
throw new IllegalStateException( "No severity declared" );
|
||||
}
|
||||
if ( version == null )
|
||||
{
|
||||
throw new IllegalStateException( "No version declared." );
|
||||
}
|
||||
this.severity = Validate.notNull( severity, "severity cannot be null" );
|
||||
this.version = Validate.notNull( version, "version cannot be null" );
|
||||
}
|
||||
|
||||
public Severity getSeverity()
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.io.InputStream;
|
|||
import java.io.Reader;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
|
@ -49,10 +50,7 @@ public class DefaultModelReader
|
|||
public Model read( File input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input file missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
Model model = read( new FileInputStream( input ), options );
|
||||
|
||||
|
@ -65,10 +63,7 @@ public class DefaultModelReader
|
|||
public Model read( Reader input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input reader missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -84,10 +79,7 @@ public class DefaultModelReader
|
|||
public Model read( InputStream input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input stream missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.io.OutputStreamWriter;
|
|||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
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,15 +47,8 @@ public class DefaultModelWriter
|
|||
public void write( File output, Map<String, Object> options, Model model )
|
||||
throws IOException
|
||||
{
|
||||
if ( output == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "output file missing" );
|
||||
}
|
||||
|
||||
if ( model == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "model missing" );
|
||||
}
|
||||
Validate.notNull( output, "output cannot be null" );
|
||||
Validate.notNull( model, "model cannot be null" );
|
||||
|
||||
output.getParentFile().mkdirs();
|
||||
|
||||
|
@ -65,15 +59,8 @@ public class DefaultModelWriter
|
|||
public void write( Writer output, Map<String, Object> options, Model model )
|
||||
throws IOException
|
||||
{
|
||||
if ( output == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "output writer missing" );
|
||||
}
|
||||
|
||||
if ( model == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "model missing" );
|
||||
}
|
||||
Validate.notNull( output, "output cannot be null" );
|
||||
Validate.notNull( model, "model cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -90,19 +77,13 @@ public class DefaultModelWriter
|
|||
public void write( OutputStream output, Map<String, Object> options, Model model )
|
||||
throws IOException
|
||||
{
|
||||
if ( output == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "output stream missing" );
|
||||
}
|
||||
|
||||
if ( model == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "model missing" );
|
||||
}
|
||||
Validate.notNull( output, "output cannot be null" );
|
||||
Validate.notNull( model, "model cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
String encoding = model.getModelEncoding();
|
||||
// TODO Use StringUtils here
|
||||
if ( encoding == null || encoding.length() <= 0 )
|
||||
{
|
||||
encoding = "UTF-8";
|
||||
|
|
|
@ -21,6 +21,7 @@ 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;
|
||||
|
@ -45,12 +46,7 @@ public abstract class AbstractProfileActivatorTest<T extends ProfileActivator>
|
|||
|
||||
public AbstractProfileActivatorTest( Class<T> activatorClass )
|
||||
{
|
||||
if ( activatorClass == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "class of profile activator to test is not specified" );
|
||||
}
|
||||
|
||||
this.activatorClass = activatorClass;
|
||||
this.activatorClass = Validate.notNull( activatorClass, "activatorClass cannot be null" );;
|
||||
|
||||
roleHint = activatorClass.getAnnotation( Component.class ).hint();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@ 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>
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
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;
|
||||
|
@ -104,10 +105,7 @@ public class ModelMerger
|
|||
*/
|
||||
public void merge( Model target, Model source, boolean sourceDominant, Map<?, ?> hints )
|
||||
{
|
||||
if ( target == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "target missing" );
|
||||
}
|
||||
Validate.notNull( target, "target cannot be null" );
|
||||
|
||||
if ( source == null )
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ under the License.
|
|||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-builder-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
|
@ -65,6 +65,10 @@ 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>
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.InputStream;
|
|||
import java.io.Reader;
|
||||
import java.util.Map;
|
||||
|
||||
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,10 +47,7 @@ public class DefaultSettingsReader
|
|||
public Settings read( File input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input file missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
Settings settings = read( ReaderFactory.newXmlReader( input ), options );
|
||||
|
||||
|
@ -60,10 +58,7 @@ public class DefaultSettingsReader
|
|||
public Settings read( Reader input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input reader missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -84,10 +79,7 @@ public class DefaultSettingsReader
|
|||
public Settings read( InputStream input, Map<String, ?> options )
|
||||
throws IOException
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "input stream missing" );
|
||||
}
|
||||
Validate.notNull( input, "input cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.io.OutputStreamWriter;
|
|||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
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,15 +47,8 @@ public class DefaultSettingsWriter
|
|||
public void write( File output, Map<String, Object> options, Settings settings )
|
||||
throws IOException
|
||||
{
|
||||
if ( output == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "output file missing" );
|
||||
}
|
||||
|
||||
if ( settings == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "settings missing" );
|
||||
}
|
||||
Validate.notNull( output, "output cannot be null" );
|
||||
Validate.notNull( settings, "settings cannot be null" );
|
||||
|
||||
output.getParentFile().mkdirs();
|
||||
|
||||
|
@ -65,15 +59,8 @@ public class DefaultSettingsWriter
|
|||
public void write( Writer output, Map<String, Object> options, Settings settings )
|
||||
throws IOException
|
||||
{
|
||||
if ( output == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "output writer missing" );
|
||||
}
|
||||
|
||||
if ( settings == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "settings missing" );
|
||||
}
|
||||
Validate.notNull( output, "output cannot be null" );
|
||||
Validate.notNull( settings, "settings cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -90,19 +77,13 @@ public class DefaultSettingsWriter
|
|||
public void write( OutputStream output, Map<String, Object> options, Settings settings )
|
||||
throws IOException
|
||||
{
|
||||
if ( output == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "output stream missing" );
|
||||
}
|
||||
|
||||
if ( settings == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "settings missing" );
|
||||
}
|
||||
Validate.notNull( output, "output cannot be null" );
|
||||
Validate.notNull( settings, "settings cannot be null" );
|
||||
|
||||
try
|
||||
{
|
||||
String encoding = settings.getModelEncoding();
|
||||
// TODO Use StringUtils here
|
||||
if ( encoding == null || encoding.length() <= 0 )
|
||||
{
|
||||
encoding = "UTF-8";
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -47,6 +47,7 @@
|
|||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<classWorldsVersion>2.5.2</classWorldsVersion>
|
||||
<commonsCliVersion>1.2</commonsCliVersion>
|
||||
<commonsLangVersion>3.4</commonsLangVersion>
|
||||
<junitVersion>4.11</junitVersion>
|
||||
<plexusVersion>1.6</plexusVersion>
|
||||
<plexusInterpolationVersion>1.21</plexusInterpolationVersion>
|
||||
|
@ -357,6 +358,11 @@
|
|||
<artifactId>commons-jxpath</artifactId>
|
||||
<version>${jxpathVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commonsLangVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.sonatype.plexus</groupId>
|
||||
<artifactId>plexus-sec-dispatcher</artifactId>
|
||||
|
@ -572,7 +578,7 @@
|
|||
<requireMavenVersion>
|
||||
<version>${maven.version}</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
Loading…
Reference in New Issue