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 @@ import org.codehaus.plexus.util.Os;
/**
* Utility class used to report errors, statistics, application version info, etc.
*
*
* @author jdcasey
*
*
*/
public final class CLIReportingUtils
{
@ -60,8 +79,8 @@ public final class CLIReportingUtils
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 @@ public final class CLIReportingUtils
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 @@ public final class CLIReportingUtils
fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
return fmt.format( new Date( time ) );
}
static Properties getBuildProperties()
{
Properties properties = new Properties();

View File

@ -68,8 +68,8 @@ final class CLIRequestUtils
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 @@ final class CLIRequestUtils
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 @@ final class CLIRequestUtils
.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 class ConsoleDownloadMonitor
{
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 class DefaultMavenExecutionRequestPopulator
}
request.setOffline( settings.isOffline() );
request.setInteractiveMode( settings.isInteractiveMode() );
request.setPluginGroups( settings.getPluginGroups() );
@ -114,7 +118,7 @@ public class DefaultMavenExecutionRequestPopulator
// <mirrorOf>*</mirrorOf>
// <url>http://repository.sonatype.org/content/groups/public</url>
// </mirror>
// </mirrors>
// </mirrors>
for ( Mirror mirror : settings.getMirrors() )
{
@ -320,7 +324,7 @@ public class DefaultMavenExecutionRequestPopulator
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 @@ public abstract class AbstractCoreMavenComponentTestCase
* 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 @@ public abstract class AbstractCoreMavenComponentTestCase
protected MavenExecutionRequest createMavenExecutionRequest( File pom )
throws Exception
{
{
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setPom( pom )
.setProjectPresent( true )
@ -107,16 +107,16 @@ public abstract class AbstractCoreMavenComponentTestCase
// 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 @@ public abstract class AbstractCoreMavenComponentTestCase
model.setVersion( "1.0" );
return new MavenProject( model );
}
protected List<ArtifactRepository> getRemoteRepositories()
throws InvalidRepositoryException
{
@ -162,28 +162,28 @@ public abstract class AbstractCoreMavenComponentTestCase
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 abstract class AbstractCoreMavenComponentTestCase
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 abstract class AbstractCoreMavenComponentTestCase
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 abstract class AbstractCoreMavenComponentTestCase
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 @@ public class MavenEmbedderTest
}
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 class MavenEmbedderTest
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 class MavenEmbedderTest
writer.close();
MavenExecutionRequest request = createMavenExecutionRequest( pom );
MavenExecutionResult result = mavenEmbedder.execute( request );
assertNoExceptions( result );
@ -164,7 +164,7 @@ public class MavenEmbedderTest
writer.close();
request = createMavenExecutionRequest( pom );
result = mavenEmbedder.execute( request );
assertNoExceptions( result );