maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject cvs commit: maven-new/core/src/java/org/apache/maven/project Project.java
Date Sun, 08 Jun 2003 22:13:11 GMT
michal      2003/06/08 15:13:08

  Modified:    core/src/java/org/apache/maven/artifact/handlers
                        NOPHandler.java PluginHandler.java
                        DefaultArtifactHandlerManager.java JarHandler.java
                        ArtifactHandlerManager.java ArtifactHandler.java
               core/src/java/org/apache/maven/artifact/processor
                        DefaultArtifactProcessor.java
               core/src/java/org/apache/maven/project Project.java
  Added:       core/src/java/org/apache/maven/artifact/handlers
                        ArtifactHandlerChain.java
                        DefaultArtifactHandlerChain.java
  Log:
  Added ArtifactHandlerChain
  
  Revision  Changes    Path
  1.6       +7 -4      maven-new/core/src/java/org/apache/maven/artifact/handlers/NOPHandler.java
  
  Index: NOPHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/NOPHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NOPHandler.java	26 May 2003 16:25:13 -0000	1.5
  +++ NOPHandler.java	8 Jun 2003 22:13:07 -0000	1.6
  @@ -64,15 +64,18 @@
    * @author Michal Maczka
    * @version $Revision$ $Date$
    */
  -public class NOPHandler
  -    implements ArtifactHandler
  +public class NOPHandler implements ArtifactHandler
   {
   
       /**
        * @see org.apache.maven.artifact.handlers.ArtifactHandler#process(org.apache.maven.artifact.Artifact,
org.apache.maven.project.Project)
        */
  -    public void process( Artifact artifact, Project project )
  +    public void process(
  +        Artifact artifact,
  +        Project project,
  +        ArtifactHandlerChain chain)
       {
  +        chain.process( artifact, project );
       }
   
   }
  
  
  
  1.5       +7 -4      maven-new/core/src/java/org/apache/maven/artifact/handlers/PluginHandler.java
  
  Index: PluginHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/PluginHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PluginHandler.java	26 May 2003 16:25:13 -0000	1.4
  +++ PluginHandler.java	8 Jun 2003 22:13:07 -0000	1.5
  @@ -66,13 +66,16 @@
    * @author Michal Maczka
    * @version $Revision$ $Date$
    */
  -public class PluginHandler
  -    implements ArtifactHandler
  +public class PluginHandler implements ArtifactHandler
   {
       /**
        * @see org.apache.maven.artifact.handlers.ArtifactHandler#process(org.apache.maven.artifact.Artifact,
org.apache.maven.project.Project)
        */
  -    public void process( Artifact artifact, Project project )
  +    public void process(
  +        Artifact artifact,
  +        Project project,
  +        ArtifactHandlerChain chain)
       {
  +       chain.process(artifact, project);
       }
   }
  
  
  
  1.6       +19 -21    maven-new/core/src/java/org/apache/maven/artifact/handlers/DefaultArtifactHandlerManager.java
  
  Index: DefaultArtifactHandlerManager.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/DefaultArtifactHandlerManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultArtifactHandlerManager.java	29 May 2003 20:26:22 -0000	1.5
  +++ DefaultArtifactHandlerManager.java	8 Jun 2003 22:13:07 -0000	1.6
  @@ -72,33 +72,34 @@
       /** Service Manager. */
       private ServiceManager serviceManager;
   
  -    /** Default Handler. */
  -    private ArtifactHandler defaultHandler;
  -
  -    /** Default role-hint tag. */
  -    private static String DEFAULT_HANDLER_ROLE_HINT = "default";
  -
       /**
  +     * 
  +     * @todo build <<real>> chain here
        * @param artifact
        * @return
        */
  -    public ArtifactHandler getHandler( Artifact artifact )
  +    public ArtifactHandlerChain getHandlerChain( Artifact artifact )
           throws MavenException
       {
           String type = artifact.getDependency().getType();
   
  -        ArtifactHandler handler = null;
  -
  +        ArtifactHandlerChain chain = new DefaultArtifactHandlerChain();
  +        
  +        /** Add handler associated with the type */
           try
           {
  -            handler = (ArtifactHandler) serviceManager.lookup( ArtifactHandler.ROLE + type);
  +            ArtifactHandler handler =
  +                (ArtifactHandler) serviceManager.lookup(
  +                    ArtifactHandler.ROLE + type);
  +            if ( handler!= null )
  +            {
  +                chain.addHandler( handler );
  +            }                           
           }
  -        catch ( ServiceException e )
  -        {
  -            handler = defaultHandler;
  +        catch (ServiceException e)
  +        {            
           }
  -
  -        return handler;
  +        return chain;
       }
   
       // ----------------------------------------------------------------------
  @@ -106,11 +107,8 @@
       // ----------------------------------------------------------------------
   
       /** @see Serviceable#service */
  -    public void service( ServiceManager serviceManager )
  -        throws ServiceException
  +    public void service(ServiceManager serviceManager) throws ServiceException
       {
  -        this.serviceManager = serviceManager;
  -
  -        defaultHandler = (ArtifactHandler) serviceManager.lookup( ArtifactHandler.ROLE
+ DEFAULT_HANDLER_ROLE_HINT );
  +        this.serviceManager = serviceManager;       
       }
   }
  
  
  
  1.8       +6 -41     maven-new/core/src/java/org/apache/maven/artifact/handlers/JarHandler.java
  
  Index: JarHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/JarHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JarHandler.java	30 May 2003 11:26:53 -0000	1.7
  +++ JarHandler.java	8 Jun 2003 22:13:07 -0000	1.8
  @@ -55,7 +55,6 @@
    */
   package org.apache.maven.artifact.handlers;
   
  -import org.apache.maven.MavenConstants;
   import org.apache.maven.artifact.Artifact;
   import org.apache.maven.project.Project;
   
  @@ -74,46 +73,12 @@
       /**
        * @see org.apache.maven.artifact.handlers.ArtifactHandler#process(org.apache.maven.artifact.Artifact,
org.apache.maven.project.Project)
        */
  -    public void process(Artifact artifact, Project project)
  +    public void process(
  +        Artifact artifact,
  +        Project project,
  +        ArtifactHandlerChain chain)
       {
  -        project.setDependencyPath(
  -            artifact.getDependency().getId(),
  -            artifact.getPath());
  -
  -        String kind = artifact.getDependency().getKind();
  -
  -        if (kind.indexOf( "global" ) != -1)
  -        {
  -            project.addToClassPath(
  -                MavenConstants.GLOBAL_DEPENDENCY_CLASSPATH,
  -                artifact.getFile().getAbsolutePath());
  -
  -        }
  -        else
  -        {
  -            if (kind.indexOf( "test" ) != -1)
  -            {
  -                project.addToClassPath(
  -                    MavenConstants.TEST_DEPENDENCY_CLASSPATH,
  -                    artifact.getFile().getAbsolutePath());
  -
  -            }
  -            if (kind.indexOf( "compile" ) != -1)
  -            {
  -                project.addToClassPath(
  -                    MavenConstants.COMPILE_DEPENDENCY_CLASSPATH,
  -                    artifact.getFile().getAbsolutePath());
  -
  -            }
  -            if (kind.indexOf( "runtime" ) != -1)
  -            {
  -                project.addToClassPath(
  -                    MavenConstants.RUNTIME_DEPENDENCY_CLASSPATH,
  -                    artifact.getFile().getAbsolutePath());
  -            }
  -
  -        }
  -
  +        chain.process( artifact, project );
       }
   
   }
  
  
  
  1.4       +5 -4      maven-new/core/src/java/org/apache/maven/artifact/handlers/ArtifactHandlerManager.java
  
  Index: ArtifactHandlerManager.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/ArtifactHandlerManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArtifactHandlerManager.java	26 May 2003 16:25:13 -0000	1.3
  +++ ArtifactHandlerManager.java	8 Jun 2003 22:13:07 -0000	1.4
  @@ -69,9 +69,10 @@
       public static final String ROLE = ArtifactHandlerManager.class.getName();
   
       /**
  -     * Returns handler for given artifact
  -     * @param artifact the Artifact for which
  +     * Returns handler chain for given artifact
  +     * @param artifact the Artifact for which the chain is constructed
        * @return the Handler which will be used for processing the artifact
        */
  -    public ArtifactHandler getHandler( Artifact artifact ) throws MavenException;
  +    public ArtifactHandlerChain getHandlerChain( Artifact artifact ) throws MavenException;
  +            
   }
  
  
  
  1.3       +2 -2      maven-new/core/src/java/org/apache/maven/artifact/handlers/ArtifactHandler.java
  
  Index: ArtifactHandler.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/handlers/ArtifactHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArtifactHandler.java	26 May 2003 16:21:01 -0000	1.2
  +++ ArtifactHandler.java	8 Jun 2003 22:13:07 -0000	1.3
  @@ -79,6 +79,6 @@
        * @param artifact the Artifact to process
        * @param project the Project, owner of the artifact
        */
  -    void process( Artifact artifact, Project project );
  +    void process( Artifact artifact, Project project, ArtifactHandlerChain chain );
   
   }
  
  
  
  1.1                  maven-new/core/src/java/org/apache/maven/artifact/handlers/ArtifactHandlerChain.java
  
  Index: ArtifactHandlerChain.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache MavenSession" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache MavenSession", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.maven.artifact.handlers;
  
  import org.apache.maven.artifact.Artifact;
  import org.apache.maven.project.Project;
  
  /**
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: ArtifactHandlerChain.java,v 1.1 2003/06/08 22:13:07 michal Exp $
   */
  public interface ArtifactHandlerChain
  {
     
     /**
      * 
      * @param artifactHandler
      */
     public void addHandler( ArtifactHandler artifactHandler );
        
     /**
      * Add artifact handler at given position
      * @param artifactHandler
      */
     public void addHandlerAt( int position,  ArtifactHandler artifactHandler );
     
     
     /**
      * Remove given handler from the chain
      * @param artifactHandler
      */
     public void removeHandler( ArtifactHandler artifactHandler );
     
     /**
      * Applay next artifact handler in this chain
      * @param artifact
      * @param project
      */
     public void process( Artifact artifact, Project project );
  
  }
  
  
  
  1.1                  maven-new/core/src/java/org/apache/maven/artifact/handlers/DefaultArtifactHandlerChain.java
  
  Index: DefaultArtifactHandlerChain.java
  ===================================================================
  /*
   * Created on 2003-06-08
   *
   * To change the template for this generated file go to
   * Window>Preferences>Java>Code Generation>Code and Comments
   */
  package org.apache.maven.artifact.handlers;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.maven.artifact.Artifact;
  import org.apache.maven.project.Project;
  
  /**
   * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
   * @version $Id: DefaultArtifactHandlerChain.java,v 1.1 2003/06/08 22:13:07 michal Exp $
   */
  public class DefaultArtifactHandlerChain implements ArtifactHandlerChain
  {
      /** List of handlers in this chain */
      private List handlers = new ArrayList();
  
      private Iterator iterator = null;
  
      /**
       * @see org.apache.maven.artifact.handlers.HandlerChain#addHandler(org.apache.maven.artifact.handlers.ArtifactHandler)
       */
      public void addHandler(ArtifactHandler artifactHandler)
      {
          handlers.add(artifactHandler);        
      }
  
      /**
       * @see org.apache.maven.artifact.handlers.HandlerChain#addHandlerAt(org.apache.maven.artifact.handlers.ArtifactHandler)
       */
      public void addHandlerAt(int position, ArtifactHandler artifactHandler)
      {
          handlers.add(position, artifactHandler);
      }
  
      /**
       * @see org.apache.maven.artifact.handlers.HandlerChain#doProccess(org.apache.maven.artifact.Artifact,
org.apache.maven.project.Project)
       */
      public void process(Artifact artifact, Project project)
      {
          if (iterator == null)
          {
              iterator = handlers.iterator();
          }
          if (iterator.hasNext())
          {
              ArtifactHandler artifactHandler = (ArtifactHandler) iterator.next();
              artifactHandler.process( artifact, project, this );
          }
      }
  
      /**
       * @see org.apache.maven.artifact.handlers.HandlerChain#removeHandler(org.apache.maven.artifact.handlers.ArtifactHandler)
       */
      public void removeHandler(ArtifactHandler artifactHandler)
      {
          handlers.remove( artifactHandler );
      }
  
  }
  
  
  
  1.6       +4 -4      maven-new/core/src/java/org/apache/maven/artifact/processor/DefaultArtifactProcessor.java
  
  Index: DefaultArtifactProcessor.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/artifact/processor/DefaultArtifactProcessor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultArtifactProcessor.java	29 May 2003 20:26:24 -0000	1.5
  +++ DefaultArtifactProcessor.java	8 Jun 2003 22:13:08 -0000	1.6
  @@ -66,6 +66,7 @@
   import org.apache.maven.artifact.Artifact;
   import org.apache.maven.artifact.factory.ArtifactFactory;
   import org.apache.maven.artifact.handlers.ArtifactHandler;
  +import org.apache.maven.artifact.handlers.ArtifactHandlerChain;
   import org.apache.maven.artifact.handlers.ArtifactHandlerManager;
   import org.apache.maven.artifact.satisfy.DependencySatisfier;
   import org.apache.maven.artifact.verify.ArtifactVerifier;
  @@ -113,9 +114,8 @@
           for (Iterator iter = artifacts.iterator(); iter.hasNext();)
           {
               Artifact artifact = (Artifact) iter.next();
  -            ArtifactHandler artifactHandler = handlerManager.getHandler( artifact );
  -            artifactHandler.process(artifact, project);
  -
  +            ArtifactHandlerChain chain = handlerManager.getHandlerChain( artifact );
  +            chain.process(artifact, project);
           }
       }
   
  
  
  
  1.9       +3 -2      maven-new/core/src/java/org/apache/maven/project/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/java/org/apache/maven/project/Project.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Project.java	30 May 2003 11:26:52 -0000	1.8
  +++ Project.java	8 Jun 2003 22:13:08 -0000	1.9
  @@ -203,7 +203,7 @@
        *  <dependency>
        *
        */
  -    private Map classpathMap;
  +    private Map classpathMap = null;
       
   
   
  @@ -232,6 +232,7 @@
       {
           dependencyPaths = new HashMap();
           dependencyMap = new HashMap();
  +        classpathMap = new HashMap();
           goalNames = new ArrayList();
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Mime
View raw message