fixed errors reported by Checkstyle (once again...)

This commit is contained in:
Hervé Boutemy 2012-12-03 02:21:58 +01:00
parent 543870467f
commit b63904c9db
25 changed files with 218 additions and 187 deletions

View File

@ -20,13 +20,10 @@ package org.apache.maven.profiles;
*/
import org.apache.maven.model.Activation;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.Profile;
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.profile.DefaultProfileActivationContext;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.apache.maven.model.profile.ProfileSelector;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.codehaus.plexus.MutablePlexusContainer;
@ -36,13 +33,11 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import org.codehaus.plexus.logging.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
@Deprecated

View File

@ -63,7 +63,7 @@ public class SystemPropertyProfileActivator
+ profile.getId() + "'" );
}
if ( name.startsWith("!") )
if ( name.startsWith( "!" ) )
{
reverseName = true;
name = name.substring( 1 );

View File

@ -1,20 +1,33 @@
package org.apache.maven.lifecycle.internal;
/*
* 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
* 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
* 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.
* 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.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
@ -37,8 +50,6 @@ import org.sonatype.aether.graph.DependencyNode;
import org.sonatype.aether.util.filter.AndDependencyFilter;
import org.sonatype.aether.util.filter.ScopeDependencyFilter;
import java.util.*;
/**
* Resolves dependencies for the artifacts in context of the lifecycle build
*
@ -49,7 +60,7 @@ import java.util.*;
* <p/>
* NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
*/
@Component(role = LifecycleDependencyResolver.class)
@Component( role = LifecycleDependencyResolver.class )
public class LifecycleDependencyResolver
{

View File

@ -52,8 +52,8 @@ class ThreadLockedArtifact
public boolean hasReal()
{
return real != null &&
( !( real instanceof ThreadLockedArtifact ) || ( (ThreadLockedArtifact) real ).hasReal() );
return real != null
&& ( !( real instanceof ThreadLockedArtifact ) || ( (ThreadLockedArtifact) real ).hasReal() );
}
public String getGroupId()
@ -96,17 +96,17 @@ class ThreadLockedArtifact
return real.hasClassifier();
}
private static final InheritableThreadLocal<ThreadLockedArtifact> threadArtifact =
private static final InheritableThreadLocal<ThreadLockedArtifact> THREAD_ARTIFACT =
new InheritableThreadLocal<ThreadLockedArtifact>();
public void attachToThread()
{
threadArtifact.set( this );
THREAD_ARTIFACT.set( this );
}
public File getFile()
{
final ThreadLockedArtifact lockedArtifact = threadArtifact.get();
final ThreadLockedArtifact lockedArtifact = THREAD_ARTIFACT.get();
if ( lockedArtifact != null && this != lockedArtifact && mustLock() )
{
try

View File

@ -66,9 +66,9 @@ public class DefaultLifecycleBindingsInjector
if ( defaultPlugins == null )
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Unknown packaging: " + packaging )
.setLocation( model.getLocation( "packaging" )));
.setLocation( model.getLocation( "packaging" ) ) );
}
else if ( !defaultPlugins.isEmpty() )
{

View File

@ -1,18 +1,22 @@
package org.apache.maven.plugin;
/*
* 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.util.List;

View File

@ -1,18 +1,22 @@
package org.apache.maven.plugin;
/*
* 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.ByteArrayOutputStream;
@ -33,7 +37,7 @@ import org.sonatype.aether.repository.RemoteRepository;
// TODO: the antrun plugin has its own configurator, the only plugin that does. might need to think about how that works
// TODO: remove the coreArtifactFilterManager
@Component(role = BuildPluginManager.class)
@Component( role = BuildPluginManager.class )
public class DefaultBuildPluginManager
implements BuildPluginManager
{

View File

@ -39,29 +39,29 @@ public class DefaultLegacySupport
implements LegacySupport
{
private static final ThreadLocal<AtomicReference<MavenSession>> session = new InheritableThreadLocal<AtomicReference<MavenSession>>();
private static final ThreadLocal<AtomicReference<MavenSession>> SESSION = new InheritableThreadLocal<AtomicReference<MavenSession>>();
public void setSession( MavenSession session )
{
AtomicReference<MavenSession> reference = DefaultLegacySupport.session.get();
AtomicReference<MavenSession> reference = DefaultLegacySupport.SESSION.get();
if ( reference != null )
{
reference.set( null);
reference.set( null );
}
if ( session == null && reference != null)
if ( session == null && reference != null )
{
DefaultLegacySupport.session.remove();
DefaultLegacySupport.SESSION.remove();
}
else
{
DefaultLegacySupport.session.set( new AtomicReference<MavenSession>( session ));
DefaultLegacySupport.SESSION.set( new AtomicReference<MavenSession>( session ) );
}
}
public MavenSession getSession()
{
AtomicReference<MavenSession> currentSession = DefaultLegacySupport.session.get();
AtomicReference<MavenSession> currentSession = DefaultLegacySupport.SESSION.get();
return currentSession != null ? currentSession.get() : null;
}

View File

@ -50,7 +50,7 @@ public interface PluginDependenciesResolver
* @return The resolved plugin artifact, never {@code null}.
* @throws PluginResolutionException If the plugin artifact could not be resolved.
*/
public Artifact resolve( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
Artifact resolve( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
throws PluginResolutionException;
/**

View File

@ -1,7 +1,5 @@
package org.apache.maven.plugin.prefix;
import org.sonatype.aether.repository.ArtifactRepository;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@ -11,7 +9,7 @@ import org.sonatype.aether.repository.ArtifactRepository;
* "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
* 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
@ -21,6 +19,8 @@ import org.sonatype.aether.repository.ArtifactRepository;
* under the License.
*/
import org.sonatype.aether.repository.ArtifactRepository;
/**
* Describes the result of a plugin prefix resolution request.
*

View File

@ -116,7 +116,7 @@ class DefaultModelBuildingListener
catch ( PluginResolutionException e )
{
event.getProblems().add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Unresolveable build extension: " + e.getMessage())
.setMessage( "Unresolveable build extension: " + e.getMessage() )
.setException( e ) );
}
catch ( PluginVersionResolutionException e )

View File

@ -1,18 +1,22 @@
package org.apache.maven.project;
/*
* 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;

View File

@ -317,7 +317,7 @@ public class DefaultModelBuilder
}
message += currentData.getId();
problems.add( new ModelProblemCollectorRequest(ModelProblem.Severity.FATAL, ModelProblem.Version.BASE).setMessage(message));
problems.add( new ModelProblemCollectorRequest( ModelProblem.Severity.FATAL, ModelProblem.Version.BASE ).setMessage( message ) );
throw problems.newModelBuildingException();
}
}
@ -409,7 +409,7 @@ public class DefaultModelBuilder
modelValidator.validateEffectiveModel( resultModel, request, problems );
if ( hasModelErrors(problems) )
if ( hasModelErrors( problems ) )
{
throw problems.newModelBuildingException();
}
@ -471,15 +471,15 @@ public class DefaultModelBuilder
if ( pomFile != null )
{
problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.V20)
.setMessage("Malformed POM " + modelSource.getLocation() + ": " + e.getMessage())
.setException(e ));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.V20 )
.setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() )
.setException( e ) );
}
else
{
problems.add( new ModelProblemCollectorRequest(Severity.WARNING, Version.V20)
.setMessage("Malformed POM " + modelSource.getLocation() + ": " + e.getMessage())
.setException(e));
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 )
.setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() )
.setException( e ) );
}
}
@ -491,9 +491,9 @@ public class DefaultModelBuilder
}
catch ( ModelParseException e )
{
problems.add( new ModelProblemCollectorRequest(Severity.FATAL, Version.BASE)
.setMessage("Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage())
.setException(e));
problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE )
.setMessage( "Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage() )
.setException( e ) );
throw problems.newModelBuildingException();
}
catch ( IOException e )
@ -511,9 +511,9 @@ public class DefaultModelBuilder
msg = e.getClass().getSimpleName();
}
}
problems.add( new ModelProblemCollectorRequest(Severity.FATAL, Version.BASE)
.setMessage("Non-readable POM " + modelSource.getLocation() + ": " + msg)
.setException(e ));
problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE )
.setMessage( "Non-readable POM " + modelSource.getLocation() + ": " + msg )
.setException( e ) );
throw problems.newModelBuildingException();
}
@ -522,7 +522,7 @@ public class DefaultModelBuilder
problems.setSource( model );
modelValidator.validateRawModel( model, request, problems );
if ( hasFatalErrors(problems) )
if ( hasFatalErrors( problems ) )
{
throw problems.newModelBuildingException();
}
@ -562,10 +562,10 @@ public class DefaultModelBuilder
}
catch ( InvalidRepositoryException e )
{
problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE)
.setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage())
.setLocation(repository.getLocation( "" ))
.setException(e) );
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Invalid repository " + repository.getId() + ": " + e.getMessage() )
.setLocation( repository.getLocation( "" ) )
.setException( e ) );
}
}
}
@ -617,9 +617,9 @@ public class DefaultModelBuilder
if ( versions.get( key ) == null && managedVersions.get( key ) == null )
{
InputLocation location = plugins.get( key ).getLocation( "" );
problems.add( new ModelProblemCollectorRequest(Severity.WARNING, Version.V20)
.setMessage( "'build.plugins.plugin.version' for " + key + " is missing.")
.setLocation(location));
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 )
.setMessage( "'build.plugins.plugin.version' for " + key + " is missing." )
.setLocation( location ) );
}
}
}
@ -694,10 +694,10 @@ public class DefaultModelBuilder
if ( !"pom".equals( parentModel.getPackaging() ) )
{
problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE)
.setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel ) + ", must be \"pom\" but is \""
+ parentModel.getPackaging() + "\"")
.setLocation(parentModel.getLocation( "packaging" )));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Invalid packaging for parent POM " + ModelProblemUtils.toSourceHint( parentModel )
+ ", must be \"pom\" but is \"" + parentModel.getPackaging() + "\"" )
.setLocation( parentModel.getLocation( "packaging" ) ) );
}
}
else
@ -749,9 +749,9 @@ public class DefaultModelBuilder
buffer.append( ", please verify your project structure" );
problems.setSource( childModel );
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE)
.setMessage( buffer.toString())
.setLocation( parent.getLocation( "" )));
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.BASE )
.setMessage( buffer.toString() )
.setLocation( parent.getLocation( "" ) ) );
return null;
}
if ( version == null || !version.equals( parent.getVersion() ) )
@ -843,10 +843,10 @@ public class DefaultModelBuilder
}
}
problems.add( new ModelProblemCollectorRequest(Severity.FATAL, Version.BASE)
.setMessage( buffer.toString())
.setLocation(parent.getLocation( "" ))
.setException(e));
problems.add( new ModelProblemCollectorRequest( Severity.FATAL, Version.BASE )
.setMessage( buffer.toString() )
.setLocation( parent.getLocation( "" ) )
.setException( e ) );
throw problems.newModelBuildingException();
}
@ -912,23 +912,26 @@ public class DefaultModelBuilder
if ( groupId == null || groupId.length() <= 0 )
{
problems.add( new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE)
.setMessage( "'dependencyManagement.dependencies.dependency.groupId' for " + dependency.getManagementKey() + " is missing.")
.setLocation( dependency.getLocation( "" )));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "'dependencyManagement.dependencies.dependency.groupId' for "
+ dependency.getManagementKey() + " is missing." )
.setLocation( dependency.getLocation( "" ) ) );
continue;
}
if ( artifactId == null || artifactId.length() <= 0 )
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
.setMessage( "'dependencyManagement.dependencies.dependency.artifactId' for " + dependency.getManagementKey() + " is missing.")
.setLocation( dependency.getLocation( "" )));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "'dependencyManagement.dependencies.dependency.artifactId' for "
+ dependency.getManagementKey() + " is missing." )
.setLocation( dependency.getLocation( "" ) ) );
continue;
}
if ( version == null || version.length() <= 0 )
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
.setMessage( "'dependencyManagement.dependencies.dependency.version' for " + dependency.getManagementKey() + " is missing.")
.setLocation( dependency.getLocation( "" )));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "'dependencyManagement.dependencies.dependency.version' for "
+ dependency.getManagementKey() + " is missing." )
.setLocation( dependency.getLocation( "" ) ) );
continue;
}
@ -942,7 +945,7 @@ public class DefaultModelBuilder
message += modelId + " -> ";
}
message += imported;
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( message ));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( message ) );
continue;
}
@ -976,8 +979,8 @@ public class DefaultModelBuilder
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( buffer.toString() )
.setLocation( dependency.getLocation( "" ))
.setException( e ));
.setLocation( dependency.getLocation( "" ) )
.setException( e ) );
continue;
}
@ -1076,24 +1079,31 @@ public class DefaultModelBuilder
&& ( version == null || message.contains( version ) );
}
protected boolean hasModelErrors(ModelProblemCollectorExt problems) {
if (problems instanceof DefaultModelProblemCollector) {
return ((DefaultModelProblemCollector)problems).hasErrors();
} else {
//the default execution path only knows the DefaultModelProblemCollector,
// only reason it's not in signature is because it's package private
throw new IllegalStateException();
protected boolean hasModelErrors( ModelProblemCollectorExt problems )
{
if ( problems instanceof DefaultModelProblemCollector )
{
return ( (DefaultModelProblemCollector) problems ).hasErrors();
}
else
{
// the default execution path only knows the DefaultModelProblemCollector,
// only reason it's not in signature is because it's package private
throw new IllegalStateException();
}
}
protected boolean hasFatalErrors(ModelProblemCollectorExt problems) {
if (problems instanceof DefaultModelProblemCollector) {
return ((DefaultModelProblemCollector)problems).hasFatalErrors();
} else {
//the default execution path only knows the DefaultModelProblemCollector,
protected boolean hasFatalErrors( ModelProblemCollectorExt problems )
{
if ( problems instanceof DefaultModelProblemCollector )
{
return ( (DefaultModelProblemCollector) problems ).hasFatalErrors();
}
else
{
// the default execution path only knows the DefaultModelProblemCollector,
// only reason it's not in signature is because it's package private
throw new IllegalStateException();
throw new IllegalStateException();
}
}

View File

@ -146,7 +146,8 @@ public class DefaultModelProblem
return severity;
}
public Version getVersion() {
public Version getVersion()
{
return version;
}

View File

@ -23,10 +23,7 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.io.ModelParseException;
/**
@ -174,7 +171,9 @@ class DefaultModelProblemCollector
column = e.getColumnNumber();
}
ModelProblem problem = new DefaultModelProblem( req.getMessage(), req.getSeverity(), req.getVersion(), source, line, column, modelId, req.getException() );
ModelProblem problem =
new DefaultModelProblem( req.getMessage(), req.getSeverity(), req.getVersion(), source, line, column,
modelId, req.getException() );
add( problem );
}

View File

@ -41,7 +41,8 @@ public interface ModelProblem
}
enum Version {
enum Version
{
//based on ModeBuildingResult.validationLevel
BASE,
V20,

View File

@ -19,9 +19,6 @@ package org.apache.maven.model.building;
* under the License.
*/
import java.util.List;
import org.apache.maven.model.InputLocation;
/**
* Collects problems that are encountered during model building. The primary purpose of this component is to account for
* the fact that the problem reporter has/should not have information about the calling context and hence cannot provide

View File

@ -1,20 +1,24 @@
/*
* Copyright 2012 The Apache Software Foundation.
*
* Licensed 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.
*/
package org.apache.maven.model.building;
/*
* 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 org.apache.maven.model.InputLocation;
import org.apache.maven.model.building.ModelProblem.Severity;
import org.apache.maven.model.building.ModelProblem.Version;
@ -38,17 +42,17 @@ public final class ModelProblemCollectorRequest
* @param severity
* @param version
*/
public ModelProblemCollectorRequest(Severity severity, Version version)
public ModelProblemCollectorRequest( Severity severity, Version version )
{
this.severity = severity;
this.version = version;
if (severity == null)
if ( severity == null )
{
throw new IllegalStateException("No severity declared");
throw new IllegalStateException( "No severity declared" );
}
if (version == null)
if ( version == null )
{
throw new IllegalStateException("No version declared.");
throw new IllegalStateException( "No version declared." );
}
}
@ -67,7 +71,7 @@ public final class ModelProblemCollectorRequest
return exception;
}
public ModelProblemCollectorRequest setException(Exception exception)
public ModelProblemCollectorRequest setException( Exception exception )
{
this.exception = exception;
return this;
@ -78,7 +82,7 @@ public final class ModelProblemCollectorRequest
return message;
}
public ModelProblemCollectorRequest setMessage(String message)
public ModelProblemCollectorRequest setMessage( String message )
{
this.message = message;
return this;
@ -89,7 +93,7 @@ public final class ModelProblemCollectorRequest
return location;
}
public ModelProblemCollectorRequest setLocation(InputLocation location)
public ModelProblemCollectorRequest setLocation( InputLocation location )
{
this.location = location;
return this;

View File

@ -45,7 +45,6 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.model.building.ModelProblem.Version;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
@ -244,7 +243,8 @@ public abstract class AbstractStringBasedModelInterpolator
}
catch ( InterpolationException e )
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( e.getMessage() ).setException( e ));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( e.getMessage() ).setException( e ) );
}
interpolator.clearFeedback();

View File

@ -20,7 +20,6 @@ package org.apache.maven.model.interpolation;
*/
import java.util.List;
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblem.Severity;
@ -65,7 +64,7 @@ class ProblemDetectingValueSource
{
msg += " Please use ${" + newPrefix + expression.substring( bannedPrefix.length() ) + "} instead.";
}
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ).setMessage( msg ));
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V20 ).setMessage( msg ) );
}
return value;

View File

@ -49,7 +49,7 @@ public class StringSearchModelInterpolator
extends AbstractStringBasedModelInterpolator
{
private static final Map<Class<?>, InterpolateObjectAction.CacheItem> cachedEntries =
private static final Map<Class<?>, InterpolateObjectAction.CacheItem> CACHED_ENTRIES =
new ConcurrentHashMap<Class<?>, InterpolateObjectAction.CacheItem>( 80, 0.75f, 2 );
// Empirical data from 3.x, actual =40
@ -161,11 +161,11 @@ public class StringSearchModelInterpolator
private CacheItem getCacheEntry( Class<?> cls )
{
CacheItem cacheItem = cachedEntries.get( cls );
CacheItem cacheItem = CACHED_ENTRIES.get( cls );
if ( cacheItem == null )
{
cacheItem = new CacheItem( cls );
cachedEntries.put( cls, cacheItem );
CACHED_ENTRIES.put( cls, cacheItem );
}
return cacheItem;
}
@ -247,7 +247,7 @@ public class StringSearchModelInterpolator
}
else if ( Collection.class.isAssignableFrom( type ) )
{
throw new RuntimeException("We dont interpolate into collections, use a list instead");
throw new RuntimeException( "We dont interpolate into collections, use a list instead" );
}
else if ( Map.class.isAssignableFrom( type ) )
{
@ -278,7 +278,7 @@ public class StringSearchModelInterpolator
}
}
static abstract class CacheField
abstract static class CacheField
{
protected final Field field;

View File

@ -108,9 +108,9 @@ public class DefaultReportingConverter
&& request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 )
{
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31)
.setMessage( "The <reporting> section is deprecated, please move the reports to the <configuration> section of the new Maven Site Plugin.")
.setLocation( reporting.getLocation( "" ) ));
problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31 )
.setMessage( "The <reporting> section is deprecated, please move the reports to the <configuration> section of the new Maven Site Plugin." )
.setLocation( reporting.getLocation( "" ) ) );
}
for ( ReportPlugin plugin : reporting.getPlugins() )

View File

@ -115,10 +115,10 @@ public class DefaultProfileSelector
}
catch ( RuntimeException e )
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
.setMessage( "Failed to determine activation for profile " + profile.getId())
.setLocation( profile.getLocation( "" ))
.setException( e ));
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Failed to determine activation for profile " + profile.getId() )
.setLocation( profile.getLocation( "" ) )
.setException( e ) );
return false;
}
}

View File

@ -65,7 +65,7 @@ public class JdkVersionProfileActivator
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Failed to determine Java version for profile " + profile.getId() )
.setLocation(activation.getLocation( "jdk" ) ) );
.setLocation( activation.getLocation( "jdk" ) ) );
return false;
}

View File

@ -62,7 +62,7 @@ public class DefaultModelValidator
implements ModelValidator
{
private static final Pattern ID_REGEX = Pattern.compile("[A-Za-z0-9_\\-.]+");
private static final Pattern ID_REGEX = Pattern.compile( "[A-Za-z0-9_\\-.]+" );
private static final String ILLEGAL_FS_CHARS = "\\/:\"<>|?*";
@ -230,8 +230,9 @@ public class DefaultModelValidator
{
if ( !"pom".equals( model.getPackaging() ) )
{
addViolation( problems, Severity.ERROR, Version.BASE,"packaging", null, "with value '" + model.getPackaging()
+ "' is invalid. Aggregator projects " + "require 'pom' as packaging.", model );
addViolation( problems, Severity.ERROR, Version.BASE, "packaging", null,
"with value '" + model.getPackaging() + "' is invalid. Aggregator projects "
+ "require 'pom' as packaging.", model );
}
for ( int i = 0, n = model.getModules().size(); i < n; i++ )
@ -850,7 +851,8 @@ public class DefaultModelValidator
buffer.append( ' ' ).append( message );
problems.add( new ModelProblemCollectorRequest( severity, version ).setMessage( buffer.toString() ).setLocation( getLocation( fieldName, tracker )));
problems.add( new ModelProblemCollectorRequest( severity, version )
.setMessage( buffer.toString() ).setLocation( getLocation( fieldName, tracker ) ) );
}
private static InputLocation getLocation( String fieldName, InputLocationTracker tracker )