maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/resources/META-INF/plexus components.xml plexus.xml
Date Sun, 13 Mar 2005 01:45:38 GMT
jvanzyl     2005/03/12 17:45:38

  Modified:    maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java
               maven-core/src/main/java/org/apache/maven/project/path
                        DefaultPathTranslator.java PathTranslator.java
               maven-core/src/main/resources/META-INF/plexus components.xml
                        plexus.xml
  Log:
  o cleaning up the path translator and adding a method to allow arbitrary
    path translation given a path and basedir
  
  o moved the component configuration for the path translator into the
    plexus.xml so that the DefaultPluginManager can use it as a dependency
  
  o DefaultPluginManager.createParameters() will now look for parameters with
    the type = java.io.File and translate the path to the basedir of the
    project.
  
  Revision  Changes    Path
  1.49      +17 -7     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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- DefaultPluginManager.java	12 Mar 2005 21:54:21 -0000	1.48
  +++ DefaultPluginManager.java	13 Mar 2005 01:45:38 -0000	1.49
  @@ -35,6 +35,7 @@
   import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
   import org.apache.maven.project.MavenProject;
   import org.apache.maven.project.MavenProjectBuilder;
  +import org.apache.maven.project.path.PathTranslator;
   import org.codehaus.plexus.ArtifactEnabledContainer;
   import org.codehaus.plexus.PlexusConstants;
   import org.codehaus.plexus.PlexusContainer;
  @@ -77,6 +78,8 @@
   
       protected ArtifactFilter artifactFilter;
   
  +    protected PathTranslator pathTranslator;
  +
       public DefaultPluginManager()
       {
           mojoDescriptors = new HashMap();
  @@ -216,8 +219,6 @@
               {
                   MavenProject project = session.getProject();
   
  -                List projectPlugins = project.getPlugins();
  -
                   org.apache.maven.model.Plugin pluginConfig = null;
   
                   for ( Iterator it = project.getPlugins().iterator(); it.hasNext(); )
  @@ -227,6 +228,7 @@
                       if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals(
plugin.getArtifactId() ) )
                       {
                           pluginConfig = plugin;
  +
                           break;
                       }
                   }
  @@ -277,6 +279,7 @@
           try
           {
               artifactResolver = (ArtifactResolver) container.lookup( ArtifactResolver.ROLE
);
  +
               mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.ROLE
);
   
               MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver,
mavenProjectBuilder );
  @@ -304,7 +307,8 @@
       // Plugin execution
       // ----------------------------------------------------------------------
   
  -    public PluginExecutionResponse executeMojo( MavenSession session, String goalName )
throws GoalExecutionException
  +    public PluginExecutionResponse executeMojo( MavenSession session, String goalName )
  +        throws GoalExecutionException
       {
           try
           {
  @@ -363,9 +367,7 @@
   
           try
           {
  -            //            getLogger().info( "[" + mojoDescriptor.getId() + "]" );
  -
  -            request = new PluginExecutionRequest( DefaultPluginManager.createParameters(
mojoDescriptor, session ) );
  +            request = new PluginExecutionRequest( createParameters( mojoDescriptor, session
) );
   
               request.setLog( session.getLog() );
           }
  @@ -444,7 +446,7 @@
       // Mojo Parameter Handling
       // ----------------------------------------------------------------------
   
  -    public static Map createParameters( MojoDescriptor goal, MavenSession session ) 
  +    public Map createParameters( MojoDescriptor goal, MavenSession session )
           throws PluginConfigurationException
       {
           Map map = null;
  @@ -473,6 +475,14 @@
                       }
                   }
   
  +                String type = parameter.getType();
  +
  +                if ( type != null && ( type.equals( "File" ) || type.equals( "java.io.File"
) ) )
  +                {
  +                    value = pathTranslator.alignToBaseDirectory( (String)value,
  +                                                                 session.getProject().getFile().getParentFile()
);
  +                }
  +
                   map.put( key, value );
               }
   
  
  
  
  1.9       +21 -56    maven-components/maven-core/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
  
  Index: DefaultPathTranslator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultPathTranslator.java	10 Mar 2005 01:35:14 -0000	1.8
  +++ DefaultPathTranslator.java	13 Mar 2005 01:45:38 -0000	1.9
  @@ -31,83 +31,48 @@
   
       public void alignToBaseDirectory( Model model, File projectFile )
       {
  -        // build.directory
  -        // build.sourceDirectory
  -        // build.unitTestSourceDirectory
  -        // build.aspectSourceDirectory
  -        // build.resources.resource.directory
  -        // unitTest.resources.resource.directory
  -
  -        // build.output
  -        // build.testOutput
  -
           Build build = model.getBuild();
   
  +        File basedir = projectFile.getParentFile();
  +
           if ( build != null )
           {
  -            String s = stripBasedirToken( build.getDirectory() );
  -
  -            if ( requiresBaseDirectoryAlignment( s ) )
  -            {
  -                build.setDirectory( new File( projectFile.getParentFile(), s ).getPath()
);
  -            }
  -
  -            s = stripBasedirToken( build.getSourceDirectory() );
  +            build.setDirectory( alignToBaseDirectory( build.getDirectory(), basedir ) );
   
  -            if ( requiresBaseDirectoryAlignment( s ) )
  -            {
  -                build.setSourceDirectory( new File( projectFile.getParentFile(), s ).getPath()
);
  -            }
  -
  -            s = stripBasedirToken( build.getTestSourceDirectory() );
  -
  -            if ( requiresBaseDirectoryAlignment( s ) )
  -            {
  -                build.setTestSourceDirectory( new File( projectFile.getParentFile(), s
).getPath() );
  -            }
  +            build.setSourceDirectory( alignToBaseDirectory( build.getSourceDirectory(),
basedir ) );
   
  -            List buildResources = build.getResources();
  +            build.setTestSourceDirectory( alignToBaseDirectory( build.getTestSourceDirectory(),
basedir ) );
   
  -            for ( Iterator i = buildResources.iterator(); i.hasNext(); )
  +            for ( Iterator i = build.getResources().iterator(); i.hasNext(); )
               {
                   Resource resource = (Resource) i.next();
   
  -                s = stripBasedirToken( resource.getDirectory() );
  -
  -                if ( requiresBaseDirectoryAlignment( s ) )
  -                {
  -                    resource.setDirectory( new File( projectFile.getParentFile(), s ).getPath()
);
  -                }
  +                resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir
) );
               }
   
  -            List unitTestResources = build.getTestResources();
  -
  -            for ( Iterator i = unitTestResources.iterator(); i.hasNext(); )
  +            for ( Iterator i = build.getTestResources().iterator(); i.hasNext(); )
               {
                   Resource resource = (Resource) i.next();
   
  -                s = stripBasedirToken( resource.getDirectory() );
  -
  -                if ( requiresBaseDirectoryAlignment( s ) )
  -                {
  -                    resource.setDirectory( new File( projectFile.getParentFile(), s ).getPath()
);
  -                }
  +                resource.setDirectory( alignToBaseDirectory( resource.getDirectory(), basedir
) );
               }
   
  -            s = stripBasedirToken( build.getOutputDirectory() );
  +            build.setOutputDirectory( alignToBaseDirectory( build.getOutputDirectory(),
basedir ) );
   
  -            if ( requiresBaseDirectoryAlignment( s ) )
  -            {
  -                build.setOutputDirectory( new File( projectFile.getParentFile(), s ).getPath()
);
  -            }
  +            build.setTestOutputDirectory( alignToBaseDirectory( build.getTestOutputDirectory(),
basedir ) );
  +        }
  +    }
   
  -            s = stripBasedirToken( build.getTestOutputDirectory() );
  +    public String alignToBaseDirectory( String path, File basedir )
  +    {
  +        String s = stripBasedirToken( path );
   
  -            if ( requiresBaseDirectoryAlignment( s ) )
  -            {
  -                build.setTestOutputDirectory( new File( projectFile.getParentFile(), s
).getPath() );
  -            }
  +        if ( requiresBaseDirectoryAlignment( s ) )
  +        {
  +            s = new File( basedir, s ).getPath();
           }
  +
  +        return s;
       }
   
       private String stripBasedirToken( String s )
  
  
  
  1.4       +3 -1      maven-components/maven-core/src/main/java/org/apache/maven/project/path/PathTranslator.java
  
  Index: PathTranslator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/path/PathTranslator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PathTranslator.java	25 Dec 2004 16:26:25 -0000	1.3
  +++ PathTranslator.java	13 Mar 2005 01:45:38 -0000	1.4
  @@ -30,4 +30,6 @@
       static final String ROLE = PathTranslator.class.getName();
   
       void alignToBaseDirectory( Model model, File projectFile );
  +
  +    String alignToBaseDirectory( String path, File basedir );
   }
  
  
  
  1.20      +0 -9      maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml
  
  Index: components.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- components.xml	9 Mar 2005 05:48:30 -0000	1.19
  +++ components.xml	13 Mar 2005 01:45:38 -0000	1.20
  @@ -109,15 +109,6 @@
        |
        -->
       <component>
  -      <role>org.apache.maven.project.path.PathTranslator</role>
  -      <implementation>org.apache.maven.project.path.DefaultPathTranslator</implementation>
  -    </component>
  -    <!--
  -     |
  -     |
  -     |
  -     -->
  -    <component>
         <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
         <implementation>org.apache.maven.artifact.factory.DefaultArtifactFactory</implementation>
       </component>
  
  
  
  1.5       +9 -0      maven-components/maven-core/src/main/resources/META-INF/plexus/plexus.xml
  
  Index: plexus.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/resources/META-INF/plexus/plexus.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- plexus.xml	25 Feb 2005 05:09:13 -0000	1.4
  +++ plexus.xml	13 Mar 2005 01:45:38 -0000	1.5
  @@ -20,6 +20,15 @@
       <component>
         <role>org.apache.maven.plugin.PluginManager</role>
         <implementation>org.apache.maven.plugin.DefaultPluginManager</implementation>
  +      <requirements>
  +        <requirement>
  +          <role>org.apache.maven.project.path.PathTranslator</role>
  +        </requirement>
  +      </requirements>
  +    </component>
  +    <component>
  +      <role>org.apache.maven.project.path.PathTranslator</role>
  +      <implementation>org.apache.maven.project.path.DefaultPathTranslator</implementation>
       </component>
     </components>
   </plexus>
  
  
  

Mime
View raw message