maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/project MavenProject.java
Date Thu, 31 Mar 2005 09:32:43 GMT
brett       2005/03/31 01:32:43

  Modified:    maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java
               maven-core/src/main/java/org/apache/maven/project
                        MavenProject.java
  Log:
  refactor plugin configuration finding and mergine into MavenProject
  
  Revision  Changes    Path
  1.74      +20 -65    maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
  
  Index: DefaultPluginManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- DefaultPluginManager.java	30 Mar 2005 08:15:36 -0000	1.73
  +++ DefaultPluginManager.java	31 Mar 2005 09:32:43 -0000	1.74
  @@ -26,7 +26,6 @@
   import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
   import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
   import org.apache.maven.execution.MavenSession;
  -import org.apache.maven.model.Goal;
   import org.apache.maven.monitor.event.EventDispatcher;
   import org.apache.maven.monitor.event.MavenEvents;
   import org.apache.maven.plugin.descriptor.MojoDescriptor;
  @@ -37,7 +36,6 @@
   import org.apache.maven.project.MavenProjectBuilder;
   import org.apache.maven.project.path.PathTranslator;
   import org.apache.maven.settings.MavenSettingsBuilder;
  -import org.apache.maven.util.Xpp3DomUtils;
   import org.codehaus.plexus.ArtifactEnabledContainer;
   import org.codehaus.plexus.PlexusConstants;
   import org.codehaus.plexus.PlexusContainer;
  @@ -386,9 +384,27 @@
               // TODO: remove
               boolean newMojoTechnique = checkMojoTechnique( plugin.getClass() );
   
  +            String goalId = null;
  +
  +            // TODO: much less of this magic is needed - make the mojoDescriptor just store
the first and second part
  +            int index = goalName.indexOf( ':' );
  +            if ( index >= 0 )
  +            {
  +                goalId = goalName.substring( index + 1 );
  +            }
  +
               // TODO: can probable refactor these a little when only the new plugin technique
is in place
  -            PlexusConfiguration configuration = getProjectDefinedPluginConfiguration( session.getProject(),
  -                                                                                      mojoDescriptor.getId()
);
  +            Xpp3Dom dom = session.getProject().getGoalConfiguration( getPluginId( goalName
), goalId );
  +
  +            PlexusConfiguration configuration;
  +            if ( dom == null )
  +            {
  +                configuration = new XmlPlexusConfiguration( "configuration" );
  +            }
  +            else
  +            {
  +                configuration = new XmlPlexusConfiguration( dom );
  +            }
   
               Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration,
session );
   
  @@ -657,67 +673,6 @@
           return map;
       }
   
  -    private static PlexusConfiguration getProjectDefinedPluginConfiguration( MavenProject
project, String goalId )
  -    {
  -        Xpp3Dom dom = null;
  -
  -        // ----------------------------------------------------------------------
  -        // I would like to be able to lookup the Plugin object using a key but
  -        // we have a limitation in modello that will be remedied shortly. So
  -        // for now I have to iterate through and see what we have.
  -        // ----------------------------------------------------------------------
  -
  -        if ( project.getPlugins() != null )
  -        {
  -            String pluginId = getPluginId( goalId );
  -
  -            for ( Iterator iterator = project.getPlugins().iterator(); iterator.hasNext();
)
  -            {
  -                org.apache.maven.model.Plugin plugin = (org.apache.maven.model.Plugin)
iterator.next();
  -
  -                // TODO: groupID not handled
  -                if ( pluginId.equals( plugin.getArtifactId() ) )
  -                {
  -                    dom = (Xpp3Dom) plugin.getConfiguration();
  -
  -                    // TODO: much less of this magic is needed - make the mojoDescriptor
just store the first and second part
  -                    int index = goalId.indexOf( ':' );
  -                    if ( index >= 0 )
  -                    {
  -                        String goalName = goalId.substring( index + 1 );
  -                        for ( Iterator j = plugin.getGoals().iterator(); j.hasNext(); )
  -                        {
  -                            Goal goal = (Goal) j.next();
  -                            if ( goal.getId().equals( goalName ) )
  -                            {
  -                                Xpp3Dom goalConfiguration = (Xpp3Dom) goal.getConfiguration();
  -                                if ( goalConfiguration != null )
  -                                {
  -                                    Xpp3Dom newDom = Xpp3DomUtils.copyXpp3Dom( goalConfiguration
);
  -                                    dom = Xpp3DomUtils.mergeXpp3Dom( newDom, dom );
  -                                }
  -                                break;
  -                            }
  -                        }
  -                    }
  -                    break;
  -                }
  -            }
  -        }
  -
  -        PlexusConfiguration configuration;
  -        if ( dom == null )
  -        {
  -            configuration = new XmlPlexusConfiguration( "configuration" );
  -        }
  -        else
  -        {
  -            configuration = new XmlPlexusConfiguration( dom );
  -        }
  -
  -        return configuration;
  -    }
  -
       public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter
parameter )
       {
           StringBuffer message = new StringBuffer();
  
  
  
  1.39      +47 -0     maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
  
  Index: MavenProject.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- MavenProject.java	29 Mar 2005 16:41:13 -0000	1.38
  +++ MavenProject.java	31 Mar 2005 09:32:43 -0000	1.39
  @@ -27,6 +27,7 @@
   import org.apache.maven.model.DependencyManagement;
   import org.apache.maven.model.Developer;
   import org.apache.maven.model.DistributionManagement;
  +import org.apache.maven.model.Goal;
   import org.apache.maven.model.IssueManagement;
   import org.apache.maven.model.License;
   import org.apache.maven.model.MailingList;
  @@ -36,9 +37,11 @@
   import org.apache.maven.model.PluginManagement;
   import org.apache.maven.model.Reports;
   import org.apache.maven.model.Scm;
  +import org.apache.maven.util.Xpp3DomUtils;
   import org.codehaus.plexus.util.dag.CycleDetectedException;
   import org.codehaus.plexus.util.dag.DAG;
   import org.codehaus.plexus.util.dag.TopologicalSorter;
  +import org.codehaus.plexus.util.xml.Xpp3Dom;
   
   import java.io.File;
   import java.util.ArrayList;
  @@ -744,5 +747,49 @@
           return distMgmtArtifactRepository;
       }
   
  +    public Xpp3Dom getGoalConfiguration( String pluginId, String goalName )
  +    {
  +        Xpp3Dom dom = null;
  +
  +        // ----------------------------------------------------------------------
  +        // I would like to be able to lookup the Plugin object using a key but
  +        // we have a limitation in modello that will be remedied shortly. So
  +        // for now I have to iterate through and see what we have.
  +        // ----------------------------------------------------------------------
  +
  +        if ( getPlugins() != null )
  +        {
  +            for ( Iterator iterator = getPlugins().iterator(); iterator.hasNext(); )
  +            {
  +                Plugin plugin = (Plugin) iterator.next();
  +
  +                // TODO: groupID not handled
  +                if ( pluginId.equals( plugin.getArtifactId() ) )
  +                {
  +                    dom = (Xpp3Dom) plugin.getConfiguration();
  +
  +                    if ( goalName != null )
  +                    {
  +                        for ( Iterator j = plugin.getGoals().iterator(); j.hasNext(); )
  +                        {
  +                            Goal goal = (Goal) j.next();
  +                            if ( goal.getId().equals( goalName ) )
  +                            {
  +                                Xpp3Dom goalConfiguration = (Xpp3Dom) goal.getConfiguration();
  +                                if ( goalConfiguration != null )
  +                                {
  +                                    Xpp3Dom newDom = Xpp3DomUtils.copyXpp3Dom( goalConfiguration
);
  +                                    dom = Xpp3DomUtils.mergeXpp3Dom( newDom, dom );
  +                                }
  +                                break;
  +                            }
  +                        }
  +                    }
  +                    break;
  +                }
  +            }
  +        }
  +        return dom;
  +    }
   }
   
  
  
  

Mime
View raw message