diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java index 65b8dae3a8..63130078a4 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java @@ -29,7 +29,7 @@ import org.apache.maven.model.resolution.ModelResolver; /** * Collects settings that control the building of effective models. - * + * * @author Benjamin Bentmann */ public interface ModelBuildingRequest @@ -39,32 +39,32 @@ public interface ModelBuildingRequest * Denotes minimal validation of POMs. This validation level is meant for processing of POMs from repositories * during metadata retrieval. */ - static final int VALIDATION_LEVEL_MINIMAL = 0; + int VALIDATION_LEVEL_MINIMAL = 0; /** * Denotes validation as performed by Maven 2.0. This validation level is meant as a compatibility mode to allow * users to migrate their projects. */ - static final int VALIDATION_LEVEL_MAVEN_2_0 = 20; + int VALIDATION_LEVEL_MAVEN_2_0 = 20; /** * Denotes validation as performed by Maven 3.0. This validation level is meant for existing projects. */ - static final int VALIDATION_LEVEL_MAVEN_3_0 = 30; + int VALIDATION_LEVEL_MAVEN_3_0 = 30; /** * Denotes validation as performed by Maven 3.1. This validation level is meant for new projects. */ - static final int VALIDATION_LEVEL_MAVEN_3_1 = 31; + int VALIDATION_LEVEL_MAVEN_3_1 = 31; /** * Denotes strict validation as recommended by the current Maven version. */ - static final int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_0; + int VALIDATION_LEVEL_STRICT = VALIDATION_LEVEL_MAVEN_3_0; /** * Gets the source of the POM to process. - * + * * @return The source of the POM or {@code null} if not set. */ ModelSource getModelSource(); @@ -72,7 +72,7 @@ public interface ModelBuildingRequest /** * Sets the source of the POM to process. Eventually, either {@link #setModelSource(ModelSource)} or * {@link #setPomFile(File)} must be set. - * + * * @param modelSource The source of the POM to process, may be {@code null}. * @return This request, never {@code null}. */ @@ -80,7 +80,7 @@ public interface ModelBuildingRequest /** * Gets the POM file of the project to build. - * + * * @return The POM file of the project or {@code null} if not applicable (i.e. when processing a POM from the * repository). */ @@ -92,7 +92,7 @@ public interface ModelBuildingRequest * build process of a local project. Hence the effective model will support the notion of a project directory. To * build the model for a POM from the repository, use {@link #setModelSource(ModelSource)} in combination with a * {@link FileModelSource} instead. - * + * * @param pomFile The POM file of the project to build the effective model for, may be {@code null} to build the * model of some POM from the repository. * @return This request, never {@code null}. @@ -101,7 +101,7 @@ public interface ModelBuildingRequest /** * Gets the level of validation to perform on processed models. - * + * * @return The level of validation to perform on processed models. */ int getValidationLevel(); @@ -111,7 +111,7 @@ public interface ModelBuildingRequest * {@link #VALIDATION_LEVEL_STRICT} should be used to ensure proper building. For the mere retrievel of dependencies * during artifact resolution, {@link #VALIDATION_LEVEL_MINIMAL} should be used to account for models of poor * quality. By default, models are validated in strict mode. - * + * * @param validationLevel The level of validation to perform on processed models. * @return This request, never {@code null}. */ @@ -121,14 +121,14 @@ public interface ModelBuildingRequest * Indicates whether plugin executions and configurations should be processed. If enabled, lifecycle-induced plugin * executions will be injected into the model and common plugin configuration will be propagated to individual * executions. - * + * * @return {@code true} if plugins should be processed, {@code false} otherwise. */ boolean isProcessPlugins(); /** * Controls the processing of plugin executions and configurations. - * + * * @param processPlugins {@code true} to enable plugin processing, {@code false} otherwise. * @return This request, never {@code null}. */ @@ -138,7 +138,7 @@ public interface ModelBuildingRequest * Indicates whether the model building should happen in two phases. If enabled, the initial invocation of the model * builder will only produce an interim result which may be used to analyze inter-model dependencies before the * final invocation of the model builder is performed. - * + * * @return {@code true} if two-phase building is enabled, {@code false} if the model should be build in a single * step. */ @@ -148,7 +148,7 @@ public interface ModelBuildingRequest * Enables/disables two-phase building. If enabled, the initial invocation of the model builder will only produce an * interim result which may be used to analyze inter-model dependencies before the final invocation of the model * builder is performed. - * + * * @param twoPhaseBuilding {@code true} to enable two-phase building, {@code false} if the model should be build in * a single step. * @return This request, never {@code null}. @@ -157,14 +157,14 @@ public interface ModelBuildingRequest /** * Gets the external profiles that should be considered for model building. - * + * * @return The external profiles that should be considered for model building, never {@code null}. */ List getProfiles(); /** * Sets the external profiles that should be considered for model building. - * + * * @param profiles The external profiles that should be considered for model building, may be {@code null}. * @return This request, never {@code null}. */ @@ -172,14 +172,14 @@ public interface ModelBuildingRequest /** * Gets the identifiers of those profiles that should be activated by explicit demand. - * + * * @return The identifiers of those profiles to activate, never {@code null}. */ List getActiveProfileIds(); /** * Sets the identifiers of those profiles that should be activated by explicit demand. - * + * * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}. * @return This request, never {@code null}. */ @@ -187,14 +187,14 @@ public interface ModelBuildingRequest /** * Gets the identifiers of those profiles that should be deactivated by explicit demand. - * + * * @return The identifiers of those profiles to deactivate, never {@code null}. */ List getInactiveProfileIds(); /** * Sets the identifiers of those profiles that should be deactivated by explicit demand. - * + * * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}. * @return This request, never {@code null}. */ @@ -203,7 +203,7 @@ public interface ModelBuildingRequest /** * Gets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. - * + * * @return The system properties, never {@code null}. */ Properties getSystemProperties(); @@ -211,7 +211,7 @@ public interface ModelBuildingRequest /** * Sets the system properties to use for interpolation and profile activation. The system properties are collected * from the runtime environment like {@link System#getProperties()} and environment variables. - * + * * @param systemProperties The system properties, may be {@code null}. * @return This request, never {@code null}. */ @@ -221,7 +221,7 @@ public interface ModelBuildingRequest * Gets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. - * + * * @return The user properties, never {@code null}. */ Properties getUserProperties(); @@ -230,7 +230,7 @@ public interface ModelBuildingRequest * Sets the user properties to use for interpolation and profile activation. The user properties have been * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command * line. - * + * * @param userProperties The user properties, may be {@code null}. * @return This request, never {@code null}. */ @@ -238,14 +238,14 @@ public interface ModelBuildingRequest /** * Gets the start time of the build. - * + * * @return The start time of the build or {@code null} if unknown. */ Date getBuildStartTime(); /** * Sets the start time of the build. - * + * * @param buildStartTime The start time of the build, may be {@code null}. * @return This request, never {@code null}. */ @@ -254,7 +254,7 @@ public interface ModelBuildingRequest /** * Gets the model resolver to use for resolution of mixins or parents that are not locally reachable from the * project directory. - * + * * @return The model resolver or {@code null} if not set. */ ModelResolver getModelResolver(); @@ -262,7 +262,7 @@ public interface ModelBuildingRequest /** * Sets the model resolver to use for resolution of mixins or parents that are not locally reachable from the * project directory. - * + * * @param modelResolver The model resolver to use, may be {@code null}. * @return This request, never {@code null}. */ @@ -270,14 +270,14 @@ public interface ModelBuildingRequest /** * Gets the model building listener to notify during the build process. - * + * * @return The model building listener to notify or {@code null} if none. */ ModelBuildingListener getModelBuildingListener(); /** * Sets the model building listener to notify during the build process. - * + * * @param modelBuildingListener The model building listener to notify, may be {@code null}. * @return This request, never {@code null}. */ @@ -285,7 +285,7 @@ public interface ModelBuildingRequest /** * Gets the model cache to use for reuse of previously built models. - * + * * @return The model cache or {@code null} if not set. */ ModelCache getModelCache(); @@ -293,7 +293,7 @@ public interface ModelBuildingRequest /** * Sets the model cache to use for reuse of previously built models. This is an optional component that serves * performance optimizations. - * + * * @param modelCache The model cache to use, may be {@code null}. * @return This request, never {@code null}. */ diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java index 2fd90923ce..90c64d6fc8 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelCacheTag.java @@ -25,7 +25,7 @@ import org.apache.maven.model.Model; /** * Describes a tag used by the model builder to access a {@link ModelCache}. This interface basically aggregates a name * and a class to provide some type safety when working with the otherwise untyped cache. - * + * * @author Benjamin Bentmann * @param The type of data associated with the tag. */ @@ -34,14 +34,14 @@ interface ModelCacheTag /** * Gets the name of the tag. - * + * * @return The name of the tag, must not be {@code null}. */ String getName(); /** * Gets the type of data associated with this tag. - * + * * @return The type of data, must not be {@code null}. */ Class getType(); @@ -49,7 +49,7 @@ interface ModelCacheTag /** * Creates a copy of the data suitable for storage in the cache. The original data to store can be mutated after the * cache is populated but the state of the cache must not change so we need to make a copy. - * + * * @param data The data to store in the cache, must not be {@code null}. * @return The data being stored in the cache, never {@code null}. */ @@ -58,7 +58,7 @@ interface ModelCacheTag /** * Creates a copy of the data suitable for retrieval from the cache. The retrieved data can be mutated after the * cache is queried but the state of the cache must not change so we need to make a copy. - * + * * @param data The data to retrieve from the cache, must not be {@code null}. * @return The data being retrieved from the cache, never {@code null}. */ @@ -67,7 +67,7 @@ interface ModelCacheTag /** * The tag used to denote raw model data. */ - public static final ModelCacheTag RAW = new ModelCacheTag() + ModelCacheTag RAW = new ModelCacheTag() { public String getName() @@ -96,7 +96,7 @@ interface ModelCacheTag /** * The tag used to denote an effective dependency management section from an imported model. */ - public static final ModelCacheTag IMPORT = new ModelCacheTag() + ModelCacheTag IMPORT = new ModelCacheTag() { public String getName() diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelEventListener.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelEventListener.java index 361fd4c037..fc58630f1c 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelEventListener.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelEventListener.java @@ -1,11 +1,30 @@ 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.Model; -public interface ModelEventListener { +public interface ModelEventListener +{ + + void fire( Model model ); - void fire(Model model); - } - diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java index cb4c482675..65caeb9ce8 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java @@ -38,7 +38,7 @@ import org.codehaus.plexus.component.annotations.Component; /** * Handles inheritance of model values. - * + * * @author Benjamin Bentmann */ @Component( role = InheritanceAssembler.class ) @@ -64,7 +64,7 @@ public class DefaultInheritanceAssembler * point at the POM rather than its base directory if the path ends with ".xml" (ignoring case). The name of the * child's base directory matches the artifact id of the child. Note that for the sake of independence from the user * environment, the filesystem is intentionally not used for the calculation. - * + * * @param child The child model, must not be null. * @param parent The parent model, may be null. * @return The path adjustment, can be empty but never null. @@ -121,9 +121,8 @@ public class DefaultInheritanceAssembler List tgt = target.getPlugins(); Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( Plugin element : src ) { - Plugin element = it.next(); Object key = getPluginKey( element ); if ( element.isInherited() ) { @@ -137,9 +136,8 @@ public class DefaultInheritanceAssembler } } - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( Plugin element : tgt ) { - Plugin element = it.next(); Object key = getPluginKey( element ); Plugin existing = merged.get( key ); if ( existing != null ) @@ -164,9 +162,8 @@ public class DefaultInheritanceAssembler Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( ReportPlugin element : src ) { - ReportPlugin element = it.next(); Object key = getReportPluginKey( element ); if ( element.isInherited() ) { @@ -180,9 +177,8 @@ public class DefaultInheritanceAssembler } } - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( ReportPlugin element : tgt ) { - ReportPlugin element = it.next(); Object key = getReportPluginKey( element ); ReportPlugin existing = merged.get( key ); if ( existing != null ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java index 8b660b872b..728b8f164a 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/AbstractStringBasedModelInterpolator.java @@ -93,11 +93,11 @@ public abstract class AbstractStringBasedModelInterpolator @Requirement private PathTranslator pathTranslator; - + private Interpolator interpolator; - + private RecursionInterceptor recursionInterceptor; - + public AbstractStringBasedModelInterpolator() { interpolator = createInterpolator(); @@ -170,7 +170,7 @@ public abstract class AbstractStringBasedModelInterpolator return valueSources; } - + protected List createPostProcessors( final Model model, final File projectDir, final ModelBuildingRequest config ) @@ -186,7 +186,7 @@ public abstract class AbstractStringBasedModelInterpolator return Collections.emptyList(); } } - + protected String interpolateInternal( String src, List valueSources, List postProcessors, ModelProblemCollector problems ) @@ -197,14 +197,14 @@ public abstract class AbstractStringBasedModelInterpolator } String result = src; - synchronized( this ) + synchronized ( this ) { - + for ( ValueSource vs : valueSources ) { interpolator.addValueSource( vs ); } - + for ( InterpolationPostProcessor postProcessor : postProcessors ) { interpolator.addPostProcessor( postProcessor ); @@ -229,7 +229,7 @@ public abstract class AbstractStringBasedModelInterpolator { interpolator.removeValuesSource( vs ); } - + for ( InterpolationPostProcessor postProcessor : postProcessors ) { interpolator.removePostProcessor( postProcessor ); @@ -239,7 +239,7 @@ public abstract class AbstractStringBasedModelInterpolator return result; } - + protected RecursionInterceptor getRecursionInterceptor() { return recursionInterceptor; @@ -251,7 +251,7 @@ public abstract class AbstractStringBasedModelInterpolator } protected abstract Interpolator createInterpolator(); - + protected final Interpolator getInterpolator() { return interpolator; diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java index a2656fbf54..fc1014eec1 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/StringSearchModelInterpolator.java @@ -52,20 +52,20 @@ public class StringSearchModelInterpolator ModelProblemCollector problems ) { interpolateObject( model, model, projectDir, config, problems ); - + return model; } - + protected void interpolateObject( Object obj, Model model, File projectDir, ModelBuildingRequest config, ModelProblemCollector problems ) { try { List valueSources = createValueSources( model, projectDir, config ); List postProcessors = createPostProcessors( model, projectDir, config ); - + InterpolateObjectAction action = new InterpolateObjectAction( obj, valueSources, postProcessors, this, problems ); - + AccessController.doPrivileged( action ); } finally @@ -78,10 +78,10 @@ public class StringSearchModelInterpolator { StringSearchInterpolator interpolator = new StringSearchInterpolator(); interpolator.setCacheAnswers( true ); - + return interpolator; } - + private static final class InterpolateObjectAction implements PrivilegedAction { @@ -90,17 +90,17 @@ public class StringSearchModelInterpolator private final List valueSources; private final List postProcessors; private final ModelProblemCollector problems; - + public InterpolateObjectAction( Object target, List valueSources, List postProcessors, StringSearchModelInterpolator modelInterpolator, ModelProblemCollector problems ) { this.valueSources = valueSources; this.postProcessors = postProcessors; - + this.interpolationTargets = new LinkedList(); interpolationTargets.add( target ); - + this.modelInterpolator = modelInterpolator; this.problems = problems; @@ -108,13 +108,13 @@ public class StringSearchModelInterpolator public Object run() { - while( !interpolationTargets.isEmpty() ) + while ( !interpolationTargets.isEmpty() ) { Object obj = interpolationTargets.removeFirst(); - + traverseObjectWithParents( obj.getClass(), obj ); } - + return null; } @@ -125,8 +125,8 @@ public class StringSearchModelInterpolator { return; } - - + + if ( cls.isArray() ) { evaluateArray( target ); @@ -139,7 +139,7 @@ public class StringSearchModelInterpolator fields = cls.getDeclaredFields(); fieldsByClass.put( cls, fields ); } - + for ( int i = 0; i < fields.length; i++ ) { Class type = fields[i].getType(); @@ -159,7 +159,7 @@ public class StringSearchModelInterpolator String interpolated = modelInterpolator.interpolateInternal( value, valueSources, postProcessors, problems ); - + if ( !interpolated.equals( value ) ) { fields[i].set( target, interpolated ); @@ -176,22 +176,22 @@ public class StringSearchModelInterpolator { c.clear(); } - catch( UnsupportedOperationException e ) + catch ( UnsupportedOperationException e ) { continue; } - + for ( Object value : originalValues ) { if ( value != null ) { - if( String.class == value.getClass() ) + if ( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, problems ); - + if ( !interpolated.equals( value ) ) { c.add( interpolated ); @@ -230,23 +230,23 @@ public class StringSearchModelInterpolator for ( Map.Entry entry : m.entrySet() ) { Object value = entry.getValue(); - + if ( value != null ) { - if( String.class == value.getClass() ) + if ( String.class == value.getClass() ) { String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, problems ); - + if ( !interpolated.equals( value ) ) { try { entry.setValue( interpolated ); } - catch( UnsupportedOperationException e ) + catch ( UnsupportedOperationException e ) { continue; } @@ -300,7 +300,7 @@ public class StringSearchModelInterpolator } } } - + traverseObjectWithParents( cls.getSuperclass(), target ); } } @@ -316,29 +316,29 @@ public class StringSearchModelInterpolator { fieldIsPrimitiveByClass.put( fieldType, Boolean.valueOf( fieldType.isPrimitive() ) ); } - + if ( fieldIsPrimitiveByClass.get( fieldType ).booleanValue() ) { return false; } - + // if ( fieldType.isPrimitive() ) // { // return false; // } - + if ( "parent".equals( field.getName() ) ) { return false; } - + return true; } private void evaluateArray( Object target ) { int len = Array.getLength( target ); - for( int i = 0; i < len; i++ ) + for ( int i = 0; i < len; i++ ) { Object value = Array.get( target, i ); if ( value != null ) @@ -348,7 +348,7 @@ public class StringSearchModelInterpolator String interpolated = modelInterpolator.interpolateInternal( (String) value, valueSources, postProcessors, problems ); - + if ( !interpolated.equals( value ) ) { Array.set( target, i, interpolated ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java b/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java index 30f2a4e5df..d8450d8f7c 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/io/ModelReader.java @@ -29,7 +29,7 @@ import org.apache.maven.model.Model; /** * Handles deserialization of a model from some kind of textual format like XML. - * + * * @author Benjamin Bentmann */ public interface ModelReader @@ -39,11 +39,11 @@ public interface ModelReader * The key for the option to enable strict parsing. This option is of type {@link Boolean} and defaults to {@code * true}. If {@code false}, unknown elements will be ignored instead of causing a failure. */ - static final String IS_STRICT = "org.apache.maven.model.io.isStrict"; + String IS_STRICT = "org.apache.maven.model.io.isStrict"; /** * Reads the model from the specified file. - * + * * @param input The file to deserialize the model from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized model, never {@code null}. @@ -56,7 +56,7 @@ public interface ModelReader /** * Reads the model from the specified character reader. The reader will be automatically closed before the method * returns. - * + * * @param input The reader to deserialize the model from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized model, never {@code null}. @@ -69,7 +69,7 @@ public interface ModelReader /** * Reads the model from the specified byte stream. The stream will be automatically closed before the method * returns. - * + * * @param input The stream to deserialize the model from, must not be {@code null}. * @param options The options to use for deserialization, may be {@code null} to use the default values. * @return The deserialized model, never {@code null}. diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java index ba3a49ca62..9edc788ac2 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java @@ -21,7 +21,6 @@ package org.apache.maven.model.management; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -36,7 +35,7 @@ import org.codehaus.plexus.component.annotations.Component; /** * Handles injection of dependency management into the model. - * + * * @author Benjamin Bentmann */ @Component( role = DependencyManagementInjector.class ) @@ -90,9 +89,8 @@ public class DefaultDependencyManagementInjector { List src = source.getExclusions(); - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( Exclusion element : src ) { - Exclusion element = it.next(); Exclusion clone = new Exclusion(); mergeExclusion( clone, element, true, context ); target.addExclusion( clone ); diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java index b7296045a5..cb45bca2dc 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultPluginManagementInjector.java @@ -21,7 +21,6 @@ package org.apache.maven.model.management; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -39,7 +38,7 @@ import org.codehaus.plexus.component.annotations.Component; /** * Handles injection of plugin management into the model. - * + * * @author Benjamin Bentmann */ @Component( role = PluginManagementInjector.class ) @@ -82,16 +81,14 @@ public class DefaultPluginManagementInjector Map context = Collections.emptyMap(); - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( Plugin element : src ) { - Plugin element = it.next(); Object key = getPluginKey( element ); managedPlugins.put( key, element ); } - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( Plugin element : tgt ) { - Plugin element = it.next(); Object key = getPluginKey( element ); Plugin managedPlugin = managedPlugins.get( key ); if ( managedPlugin != null ) @@ -114,18 +111,16 @@ public class DefaultPluginManagementInjector Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( PluginExecution element : src ) { - PluginExecution element = it.next(); Object key = getPluginExecutionKey( element ); PluginExecution clone = new PluginExecution(); mergePluginExecution( clone, element, true, context ); merged.put( key, clone ); } - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( PluginExecution element : tgt ) { - PluginExecution element = it.next(); Object key = getPluginExecutionKey( element ); PluginExecution existing = merged.get( key ); if ( existing != null ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java index edaa8613a6..67b3d9514f 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java @@ -54,7 +54,7 @@ import org.apache.maven.model.Site; /** * The domain-specific model merger for the Maven POM. - * + * * @author Benjamin Bentmann */ public class MavenModelMerger @@ -78,7 +78,7 @@ public class MavenModelMerger super.mergeModel( target, source, sourceDominant, context ); } - + @Override protected void mergeModel_Name( Model target, Model source, boolean sourceDominant, Map context ) { @@ -124,7 +124,8 @@ public class MavenModelMerger Organization tgt = target.getOrganization(); if ( tgt == null ) { - target.setOrganization( tgt = new Organization() ); + tgt = new Organization(); + target.setOrganization( tgt ); mergeOrganization( tgt, src, sourceDominant, context ); } } @@ -140,7 +141,8 @@ public class MavenModelMerger IssueManagement tgt = target.getIssueManagement(); if ( tgt == null ) { - target.setIssueManagement( tgt = new IssueManagement() ); + tgt = new IssueManagement(); + target.setIssueManagement( tgt ); mergeIssueManagement( tgt, src, sourceDominant, context ); } } @@ -156,7 +158,8 @@ public class MavenModelMerger CiManagement tgt = target.getCiManagement(); if ( tgt == null ) { - target.setCiManagement( tgt = new CiManagement() ); + tgt = new CiManagement(); + target.setCiManagement( tgt ); mergeCiManagement( tgt, src, sourceDominant, context ); } } @@ -261,16 +264,14 @@ public class MavenModelMerger recessive = src; } - for ( Iterator it = dominant.iterator(); it.hasNext(); ) + for ( Repository element : dominant ) { - Repository element = it.next(); Object key = getRepositoryKey( element ); merged.put( key, element ); } - for ( Iterator it = recessive.iterator(); it.hasNext(); ) + for ( Repository element : recessive ) { - Repository element = it.next(); Object key = getRepositoryKey( element ); if ( !merged.containsKey( key ) ) { @@ -338,7 +339,8 @@ public class MavenModelMerger DeploymentRepository tgt = target.getRepository(); if ( tgt == null ) { - target.setRepository( tgt = new DeploymentRepository() ); + tgt = new DeploymentRepository(); + target.setRepository( tgt ); mergeDeploymentRepository( tgt, src, sourceDominant, context ); } } @@ -355,7 +357,8 @@ public class MavenModelMerger DeploymentRepository tgt = target.getSnapshotRepository(); if ( tgt == null ) { - target.setSnapshotRepository( tgt = new DeploymentRepository() ); + tgt = new DeploymentRepository(); + target.setSnapshotRepository( tgt ); mergeDeploymentRepository( tgt, src, sourceDominant, context ); } } @@ -371,7 +374,8 @@ public class MavenModelMerger Site tgt = target.getSite(); if ( tgt == null ) { - target.setSite( tgt = new Site() ); + tgt = new Site(); + target.setSite( tgt ); mergeSite( tgt, src, sourceDominant, context ); } } @@ -461,9 +465,8 @@ public class MavenModelMerger Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( PluginExecution element : src ) { - PluginExecution element = it.next(); if ( sourceDominant || ( source.isInherited() && element.isInherited() ) ) { Object key = getPluginExecutionKey( element ); @@ -471,9 +474,8 @@ public class MavenModelMerger } } - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( PluginExecution element : tgt ) { - PluginExecution element = it.next(); Object key = getPluginExecutionKey( element ); PluginExecution existing = merged.get( key ); if ( existing != null ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java index 61336181b4..0a497d5195 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java @@ -21,7 +21,6 @@ package org.apache.maven.model.profile; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -42,7 +41,7 @@ import org.codehaus.plexus.component.annotations.Component; /** * Handles profile injection into the model. - * + * * @author Benjamin Bentmann */ @Component( role = ProfileInjector.class ) @@ -94,16 +93,14 @@ public class DefaultProfileInjector List tgt = target.getPlugins(); Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( Plugin element : tgt ) { - Plugin element = it.next(); Object key = getPluginKey( element ); merged.put( key, element ); } - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( Plugin element : src ) { - Plugin element = it.next(); Object key = getPluginKey( element ); Plugin existing = merged.get( key ); if ( existing == null ) @@ -131,16 +128,14 @@ public class DefaultProfileInjector Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); - for ( Iterator it = tgt.iterator(); it.hasNext(); ) + for ( ReportPlugin element : tgt ) { - ReportPlugin element = it.next(); Object key = getReportPluginKey( element ); merged.put( key, element ); } - for ( Iterator it = src.iterator(); it.hasNext(); ) + for ( ReportPlugin element : src ) { - ReportPlugin element = it.next(); Object key = getReportPluginKey( element ); ReportPlugin existing = merged.get( key ); if ( existing == null ) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java index fdf3d8700c..8dfb6c3a2a 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java @@ -121,15 +121,15 @@ public class DefaultModelValidator if ( !model.getModules().isEmpty() && !"pom".equals( model.getPackaging() ) ) { - addViolation( problems, false, "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " + - "require 'pom' as packaging." ); + addViolation( problems, false, "Packaging '" + model.getPackaging() + "' is invalid. Aggregator projects " + + "require 'pom' as packaging." ); } Parent parent = model.getParent(); if ( parent != null ) { - if ( parent.getGroupId().equals( model.getGroupId() ) && - parent.getArtifactId().equals( model.getArtifactId() ) ) + if ( parent.getGroupId().equals( model.getGroupId() ) + && parent.getArtifactId().equals( model.getArtifactId() ) ) { addViolation( problems, false, "The parent element cannot have the same ID as the project." ); } @@ -163,8 +163,8 @@ public class DefaultModelValidator { if ( !new File( systemPath ).isAbsolute() ) { - addViolation( problems, false, "For dependency " + d + ": system-scoped dependency must " + - "specify an absolute path systemPath." ); + addViolation( problems, false, "For dependency " + d + ": system-scoped dependency must " + + "specify an absolute path systemPath." ); } } } @@ -208,8 +208,8 @@ public class DefaultModelValidator { if ( !new File( systemPath ).isAbsolute() ) { - addViolation( problems, false, "For managed dependency " + d + ": system-scoped dependency must " + - "specify an absolute path systemPath." ); + addViolation( problems, false, "For managed dependency " + d + ": system-scoped dependency must " + + "specify an absolute path systemPath." ); } } }