fixed errors reported by Checkstyle

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@813615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Herve Boutemy 2009-09-10 22:05:49 +00:00
parent b82977a18c
commit af5b761568
6 changed files with 109 additions and 86 deletions

View File

@ -1,5 +1,24 @@
package org.apache.maven.cli;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
@ -15,9 +34,9 @@
/**
* Utility class used to report errors, statistics, application version info, etc.
*
*
* @author jdcasey
*
*
*/
public final class CLIReportingUtils
{
@ -60,8 +79,8 @@ public static void showVersion()
System.out.println( "Default locale: " + Locale.getDefault() + ", platform encoding: "
+ System.getProperty( "file.encoding", "<unknown encoding>" ) );
System.out.println( "OS name: \"" + Os.OS_NAME + "\" version: \"" + Os.OS_VERSION +
"\" arch: \"" + Os.OS_ARCH + "\" Family: \"" + Os.OS_FAMILY + "\"" );
System.out.println( "OS name: \"" + Os.OS_NAME + "\" version: \"" + Os.OS_VERSION
+ "\" arch: \"" + Os.OS_ARCH + "\" Family: \"" + Os.OS_FAMILY + "\"" );
}
private static String reduce( String s )
@ -69,7 +88,7 @@ private static String reduce( String s )
return ( s != null ? ( s.startsWith( "${" ) && s.endsWith( "}" ) ? null : s ) : null );
}
private static void stats( Date start, MavenEmbedderLogger logger )
{
Date finish = new Date();
@ -137,7 +156,7 @@ private static String getFormattedTime( long time )
fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
return fmt.format( new Date( time ) );
}
static Properties getBuildProperties()
{
Properties properties = new Properties();

View File

@ -68,8 +68,8 @@ public static MavenExecutionRequest populateRequest( MavenExecutionRequest reque
boolean pluginUpdateOverride = false;
if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES ) ||
commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES2 ) )
if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES )
|| commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES2 ) )
{
pluginUpdateOverride = true;
}
@ -151,7 +151,7 @@ else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) )
String [] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES );
if ( profileOptionValues != null )
{
for ( int i=0; i < profileOptionValues.length; ++i )
for ( int i = 0; i < profileOptionValues.length; ++i )
{
StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i] , "," );
@ -244,22 +244,22 @@ else if ( quiet )
.setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
.setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
.setUserToolchainsFile( userToolchainsFile );
File pom;
if ( alternatePomFile != null )
{
pom = new File( alternatePomFile );
}
else
{
pom = new File( baseDirectory, Maven.POMv4 );
pom = new File( baseDirectory, Maven.POMv4 );
}
if ( pom.exists() )
{
request.setPom( pom );
}
}
if ( commandLine.hasOption( CLIManager.RESUME_FROM ) )
{

View File

@ -43,18 +43,18 @@ public void transferProgress( TransferEvent transferEvent, byte[] buffer, int le
{
long total = transferEvent.getResource().getContentLength();
complete += length;
if ( !showEvent( transferEvent ) )
{
return;
}
// TODO [BP]: Sys.out may no longer be appropriate, but will \r work with getLogger()?
if ( total >= 1024 )
{
System.out.print(
( complete / 1024 ) + "/" + ( total == WagonConstants.UNKNOWN_LENGTH ? "?" : ( total / 1024 ) + "K" ) +
"\r" );
( complete / 1024 ) + "/" + ( total == WagonConstants.UNKNOWN_LENGTH ? "?" : ( total / 1024 ) + "K" )
+ "\r" );
}
else
{

View File

@ -1,18 +1,22 @@
package org.apache.maven.embedder.execution;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
@ -62,7 +66,7 @@ public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request
}
request.setOffline( settings.isOffline() );
request.setInteractiveMode( settings.isInteractiveMode() );
request.setPluginGroups( settings.getPluginGroups() );
@ -114,7 +118,7 @@ public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request
// <mirrorOf>*</mirrorOf>
// <url>http://repository.sonatype.org/content/groups/public</url>
// </mirror>
// </mirrors>
// </mirrors>
for ( Mirror mirror : settings.getMirrors() )
{
@ -320,7 +324,7 @@ public MavenExecutionRequest populateDefaults( MavenExecutionRequest request )
populateDefaultPluginGroups( request );
injectDefaultRepositories( request );
injectDefaultPluginRepositories( request );
processRepositoriesInSettings( request );

View File

@ -39,7 +39,7 @@ public abstract class AbstractCoreMavenComponentTestCase
@Requirement
protected Maven maven;
protected void setUp()
throws Exception
{
@ -75,7 +75,7 @@ protected File getProject( String name )
* We need to customize the standard Plexus container with the plugin discovery listener which
* is what looks for the META-INF/maven/plugin.xml resources that enter the system when a Maven
* plugin is loaded.
*
*
* We also need to customize the Plexus container with a standard plugin discovery listener
* which is the MavenPluginCollector. When a Maven plugin is discovered the MavenPluginCollector
* collects the plugin descriptors which are found.
@ -88,7 +88,7 @@ protected void customizeContainerConfiguration( ContainerConfiguration container
protected MavenExecutionRequest createMavenExecutionRequest( File pom )
throws Exception
{
{
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setPom( pom )
.setProjectPresent( true )
@ -107,16 +107,16 @@ protected MavenExecutionRequest createMavenExecutionRequest( File pom )
// a Maven subclass because we don't want to couple maven to the project builder which we need to
// separate.
protected MavenSession createMavenSession( File pom )
throws Exception
throws Exception
{
return createMavenSession( pom, new Properties() );
}
protected MavenSession createMavenSession( File pom, Properties executionProperties )
throws Exception
{
MavenExecutionRequest request = createMavenExecutionRequest( pom );
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest()
.setLocalRepository( request.getLocalRepository() )
.setRemoteRepositories( request.getRemoteRepositories() )
@ -147,7 +147,7 @@ protected MavenProject createStubMavenProject()
model.setVersion( "1.0" );
return new MavenProject( model );
}
protected List<ArtifactRepository> getRemoteRepositories()
throws InvalidRepositoryException
{
@ -162,28 +162,28 @@ protected List<ArtifactRepository> getPluginArtifactRepositories()
itRepo.setUrl( "http://repository.sonatype.org/content/repositories/maven.snapshots" );
return Arrays.asList( repositorySystem.createDefaultRemoteRepository(), repositorySystem.buildArtifactRepository( itRepo ) );
}
protected ArtifactRepository getLocalRepository()
protected ArtifactRepository getLocalRepository()
throws InvalidRepositoryException
{
return repositorySystem.createDefaultLocalRepository();
{
return repositorySystem.createDefaultLocalRepository();
}
protected class ProjectBuilder
{
private MavenProject project;
public ProjectBuilder( String groupId, String artifactId, String version )
{
Model model = new Model();
model.setModelVersion( "4.0.0" );
model.setGroupId( groupId );
model.setArtifactId( artifactId );
model.setVersion( version );
model.setVersion( version );
model.setBuild( new Build() );
project = new MavenProject( model );
project = new MavenProject( model );
}
public ProjectBuilder setGroupId( String groupId )
{
project.setGroupId( groupId );
@ -195,30 +195,30 @@ public ProjectBuilder setArtifactId( String artifactId )
project.setArtifactId( artifactId );
return this;
}
public ProjectBuilder setVersion( String version )
{
project.setVersion( version );
return this;
}
// Dependencies
//
public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope )
{
return addDependency( groupId, artifactId, version, scope, (Exclusion)null );
return addDependency( groupId, artifactId, version, scope, (Exclusion) null );
}
public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, Exclusion exclusion )
{
return addDependency( groupId, artifactId, version, scope, null, exclusion );
return addDependency( groupId, artifactId, version, scope, null, exclusion );
}
public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath )
{
return addDependency( groupId, artifactId, version, scope, systemPath, null );
return addDependency( groupId, artifactId, version, scope, systemPath, null );
}
public ProjectBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion )
{
Dependency d = new Dependency();
@ -226,60 +226,60 @@ public ProjectBuilder addDependency( String groupId, String artifactId, String v
d.setArtifactId( artifactId );
d.setVersion( version );
d.setScope( scope );
if ( systemPath != null && scope.equals( Artifact.SCOPE_SYSTEM ) )
{
d.setSystemPath( systemPath );
}
if ( exclusion != null )
{
d.addExclusion( exclusion );
}
project.getDependencies().add( d );
return this;
}
// Plugins
//
public ProjectBuilder addPlugin( Plugin plugin )
{
project.getBuildPlugins().add( plugin );
project.getBuildPlugins().add( plugin );
return this;
}
public MavenProject get()
{
return project;
}
}
}
}
protected class PluginBuilder
{
private Plugin plugin;
public PluginBuilder( String groupId, String artifactId, String version )
{
plugin = new Plugin();
plugin.setGroupId( groupId );
plugin.setArtifactId( artifactId );
plugin.setVersion( version );
plugin.setVersion( version );
}
// Dependencies
//
public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, Exclusion exclusion )
{
return addDependency( groupId, artifactId, version, scope, exclusion );
return addDependency( groupId, artifactId, version, scope, exclusion );
}
public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath )
{
return addDependency( groupId, artifactId, version, scope, systemPath, null );
return addDependency( groupId, artifactId, version, scope, systemPath, null );
}
public PluginBuilder addDependency( String groupId, String artifactId, String version, String scope, String systemPath, Exclusion exclusion )
{
Dependency d = new Dependency();
@ -287,25 +287,25 @@ public PluginBuilder addDependency( String groupId, String artifactId, String ve
d.setArtifactId( artifactId );
d.setVersion( version );
d.setScope( scope );
if ( systemPath != null && scope.equals( Artifact.SCOPE_SYSTEM ) )
{
d.setSystemPath( systemPath );
}
if ( exclusion != null )
{
d.addExclusion( exclusion );
}
plugin.getDependencies().add( d );
return this;
}
public Plugin get()
{
return plugin;
}
}
}
}
}

View File

@ -86,14 +86,14 @@ protected void assertNoExceptions( MavenExecutionResult result )
}
System.err.println( "Encountered " + exceptions.size() + " exception(s)." );
for (Exception exception : exceptions)
for ( Exception exception : exceptions )
{
exception.printStackTrace( System.err );
}
fail( "Encountered Exceptions in MavenExecutionResult during " + getName() );
}
/*MNG-3919*/
public void testWithInvalidGoal()
throws Exception
@ -104,16 +104,16 @@ public void testWithInvalidGoal()
FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
MavenExecutionRequest request = createMavenExecutionRequest( new File( targetDirectory, "pom.xml" ) );
MavenExecutionRequest request = createMavenExecutionRequest( new File( targetDirectory, "pom.xml" ) );
request.setGoals( Arrays.asList( new String[]{"validate"} ) );
MavenExecutionResult result = mavenEmbedder.execute( request );
List<Exception> exceptions = result.getExceptions();
assertEquals("Incorrect number of exceptions", 1, exceptions.size());
assertEquals( "Incorrect number of exceptions", 1, exceptions.size() );
if ( ( exceptions.get( 0 ) instanceof NullPointerException ) )
{
fail("Null Pointer on Exception");
fail( "Null Pointer on Exception" );
}
}
@ -147,7 +147,7 @@ public void testTwoExecutionsDoNotCacheChangedData()
writer.close();
MavenExecutionRequest request = createMavenExecutionRequest( pom );
MavenExecutionResult result = mavenEmbedder.execute( request );
assertNoExceptions( result );
@ -164,7 +164,7 @@ public void testTwoExecutionsDoNotCacheChangedData()
writer.close();
request = createMavenExecutionRequest( pom );
result = mavenEmbedder.execute( request );
assertNoExceptions( result );