code simplification

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@956708 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Herve Boutemy 2010-06-21 21:42:55 +00:00
parent fc64c716a1
commit 79d62ed13c
3 changed files with 18 additions and 37 deletions

View File

@ -108,7 +108,7 @@ public class MojoDescriptor
/** Plugin descriptor */
private PluginDescriptor pluginDescriptor;
/** By default, the Mojo is herited */
/** By default, the Mojo is inherited */
private boolean inheritedByDefault = true;
/** By default, the Mojo could not be invoke directly */
@ -200,14 +200,14 @@ public class MojoDescriptor
+ getImplementation() + ")" );
}
if ( parameters == null )
{
parameters = new LinkedList<Parameter>();
}
parameters.add( parameter );
if ( parameters == null )
{
parameters = new LinkedList<Parameter>();
}
parameters.add( parameter );
}
/**
* @return the list parameters as a Map
*/
@ -535,12 +535,7 @@ public class MojoDescriptor
return false;
}
if ( !first.equals( second ) )
{
return false;
}
return true;
return first.equals( second );
}
/** {@inheritDoc} */

View File

@ -28,7 +28,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -281,20 +280,15 @@ public class PluginDescriptor
}
// TODO: could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to
// changes above not being propogated to the map
MojoDescriptor mojoDescriptor = null;
for ( Iterator<?> i = getMojos().iterator(); i.hasNext() && mojoDescriptor == null; )
// changes above not being propagated to the map
for ( MojoDescriptor desc : getMojos() )
{
MojoDescriptor desc = (MojoDescriptor) i.next();
if ( goal.equals( desc.getGoal() ) )
{
mojoDescriptor = desc;
return desc;
}
}
return mojoDescriptor;
return null;
}
public void setClassRealm( ClassRealm classRealm )

View File

@ -55,7 +55,7 @@ public class PluginDescriptorBuilder
pluginDescriptor.setArtifactId( c.getChild( "artifactId" ).getValue() );
pluginDescriptor.setVersion( c.getChild( "version" ).getValue() );
pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() );
pluginDescriptor.setName( c.getChild( "name" ).getValue() );
pluginDescriptor.setDescription( c.getChild( "description" ).getValue() );
@ -79,10 +79,8 @@ public class PluginDescriptorBuilder
PlexusConfiguration[] mojoConfigurations = c.getChild( "mojos" ).getChildren( "mojo" );
for ( int i = 0; i < mojoConfigurations.length; i++ )
for ( PlexusConfiguration component : mojoConfigurations )
{
PlexusConfiguration component = mojoConfigurations[i];
MojoDescriptor mojoDescriptor = buildComponentDescriptor( component, pluginDescriptor );
pluginDescriptor.addMojo( mojoDescriptor );
@ -96,10 +94,8 @@ public class PluginDescriptorBuilder
List<ComponentDependency> dependencies = new ArrayList<ComponentDependency>();
for ( int i = 0; i < dependencyConfigurations.length; i++ )
for ( PlexusConfiguration d : dependencyConfigurations )
{
PlexusConfiguration d = dependencyConfigurations[i];
ComponentDependency cd = new ComponentDependency();
cd.setArtifactId( d.getChild( "artifactId" ).getValue() );
@ -125,7 +121,7 @@ public class PluginDescriptorBuilder
mojo.setPluginDescriptor( pluginDescriptor );
mojo.setGoal( c.getChild( "goal" ).getValue() );
mojo.setImplementation( c.getChild( "implementation" ).getValue() );
PlexusConfiguration langConfig = c.getChild( "language" );
@ -266,10 +262,8 @@ public class PluginDescriptorBuilder
List<Parameter> parameters = new ArrayList<Parameter>();
for ( int i = 0; i < parameterConfigurations.length; i++ )
for ( PlexusConfiguration d : parameterConfigurations )
{
PlexusConfiguration d = parameterConfigurations[i];
Parameter parameter = new Parameter();
parameter.setName( d.getChild( "name" ).getValue() );
@ -320,10 +314,8 @@ public class PluginDescriptorBuilder
PlexusConfiguration[] requirements = c.getChild( "requirements" ).getChildren( "requirement" );
for ( int i = 0; i < requirements.length; i++ )
for ( PlexusConfiguration requirement : requirements )
{
PlexusConfiguration requirement = requirements[i];
ComponentRequirement cr = new ComponentRequirement();
cr.setRole( requirement.getChild( "role" ).getValue() );