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/test/java/org/apache/maven/project DefaultProjectDefaultsInjectorTest.java
Date Wed, 23 Feb 2005 01:59:34 GMT
brett       2005/02/22 17:59:34

  Modified:    maven-core/src/main/java/org/apache/maven/project
                        DefaultMavenProjectBuilder.java MavenProject.java
               maven-core/src/main/resources/META-INF/plexus components.xml
               maven-core/src/test/java/org/apache/maven/project
                        DefaultProjectDefaultsInjectorTest.java
  Added:       maven-core/src/main/java/org/apache/maven/project/injection
                        DefaultProjectDefaultsInjector.java
                        ProjectDefaultsInjector.java
  Removed:     maven-core/src/main/java/org/apache/maven/project
                        DefaultProjectDefaultsInjector.java
                        ProjectDefaultsInjector.java
  Log:
  move injectors to a package
  
  Revision  Changes    Path
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/project/injection/DefaultProjectDefaultsInjector.java
  
  Index: DefaultProjectDefaultsInjector.java
  ===================================================================
  package org.apache.maven.project.injection;
  
  /*
   * Copyright 2001-2005 The Apache Software Foundation.
   *
   * Licensed 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.Dependency;
  import org.apache.maven.model.DependencyManagement;
  import org.apache.maven.project.MavenProject;
  
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Properties;
  import java.util.TreeMap;
  
  /**
   * @author jdcasey Created on Feb 1, 2005
   */
  public class DefaultProjectDefaultsInjector
      implements ProjectDefaultsInjector
  {
  
      public void injectDefaults( MavenProject project )
      {
          injectDependencyDefaults( project.getDependencies(), project.getDependencyManagement()
);
      }
  
      /**
       * Added: Feb 1, 2005 by jdcasey
       */
      private void injectDependencyDefaults( List dependencies, DependencyManagement dependencyManagement
)
      {
          if ( dependencyManagement != null )
          {
              // a given project's dependencies should be smaller than the
              // group-defined defaults set...
              // in other words, the project's deps will probably be a subset of
              // those specified in defaults.
              Map depsMap = new TreeMap();
              for ( Iterator it = dependencies.iterator(); it.hasNext(); )
              {
                  Dependency dep = (Dependency) it.next();
                  depsMap.put( dep.getManagementKey(), dep );
              }
  
              List dependencyDefaults = dependencyManagement.getDependencies();
  
              for ( Iterator it = dependencyDefaults.iterator(); it.hasNext(); )
              {
                  Dependency def = (Dependency) it.next();
                  String key = def.getManagementKey();
  
                  Dependency dep = (Dependency) depsMap.get( key );
                  if ( dep != null )
                  {
                      mergeWithDefaults( dep, def );
                  }
              }
          }
      }
  
      /**
       * Added: Feb 1, 2005 by jdcasey
       */
      private void mergeWithDefaults( Dependency dep, Dependency def )
      {
          if ( dep.getVersion() == null && def.getVersion() != null )
          {
              dep.setVersion( def.getVersion() );
          }
  
          Properties props = new Properties( def.getProperties() );
          props.putAll( dep.getProperties() );
          dep.setProperties( props );
      }
  
  }
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/project/injection/ProjectDefaultsInjector.java
  
  Index: ProjectDefaultsInjector.java
  ===================================================================
  package org.apache.maven.project.injection;
  
  /*
   * Copyright 2001-2005 The Apache Software Foundation.
   *
   * Licensed 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.project.MavenProject; /**
   * @author jdcasey Created on Feb 1, 2005
   */
  public interface ProjectDefaultsInjector
  {
      String ROLE = ProjectDefaultsInjector.class.getName();
  
      void injectDefaults( MavenProject project );
  }
  
  
  1.31      +1 -0      maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
  
  Index: DefaultMavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DefaultMavenProjectBuilder.java	8 Feb 2005 06:02:40 -0000	1.30
  +++ DefaultMavenProjectBuilder.java	23 Feb 2005 01:59:34 -0000	1.31
  @@ -31,6 +31,7 @@
   import org.apache.maven.model.Parent;
   import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
   import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
  +import org.apache.maven.project.injection.ProjectDefaultsInjector;
   import org.apache.maven.project.interpolation.ProjectInterpolator;
   import org.apache.maven.project.path.PathTranslator;
   import org.apache.maven.project.validation.ModelValidationResult;
  
  
  
  1.17      +2 -2      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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- MavenProject.java	8 Feb 2005 04:12:57 -0000	1.16
  +++ MavenProject.java	23 Feb 2005 01:59:34 -0000	1.17
  @@ -17,7 +17,6 @@
    * ====================================================================
    */
   
  -import org.apache.maven.artifact.Artifact;
   import org.apache.maven.model.Build;
   import org.apache.maven.model.CiManagement;
   import org.apache.maven.model.Contributor;
  @@ -34,7 +33,6 @@
   
   import java.io.File;
   import java.util.ArrayList;
  -import java.util.Iterator;
   import java.util.List;
   import java.util.Set;
   
  @@ -203,6 +201,7 @@
           return list;
       }
   
  +/* TODO: remove - should be using a type handler
       public String[] getClasspathElements()
       {
           int size = getArtifacts().size();
  @@ -238,6 +237,7 @@
           return false;
       }
   
  +*/
       // ----------------------------------------------------------------------
       // Delegate to the model
       // ----------------------------------------------------------------------
  
  
  
  1.12      +5 -5      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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- components.xml	19 Feb 2005 14:47:09 -0000	1.11
  +++ components.xml	23 Feb 2005 01:59:34 -0000	1.12
  @@ -86,8 +86,8 @@
        |
        -->
       <component>
  -      <role>org.apache.maven.project.ProjectDefaultsInjector</role>
  -      <implementation>org.apache.maven.project.DefaultProjectDefaultsInjector</implementation>
  +      <role>org.apache.maven.project.injection.ProjectDefaultsInjector</role>
  +      <implementation>org.apache.maven.project.injection.DefaultProjectDefaultsInjector</implementation>
       </component>
       <!--
        |
  @@ -99,7 +99,7 @@
         <implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
         <requirements>
           <requirement>
  -          <role>org.apache.maven.project.ProjectDefaultsInjector</role>
  +          <role>org.apache.maven.project.injection.ProjectDefaultsInjector</role>
           </requirement>
           <requirement>
             <role>org.apache.maven.project.interpolation.ProjectInterpolator</role>
  @@ -255,12 +255,12 @@
             <!-- 14 -->
             <phase>
               <id>install</id>
  -            <goal>install:install</goal>
  +            <goal>jar:install</goal>
             </phase>
             <!-- 15 -->
             <phase>
               <id>deploy</id>
  -            <goal>deploy:deploy</goal>
  +            <goal>jar:deploy</goal>
             </phase>
           </phases>
           <!-- END SNIPPET: lifecycle -->
  
  
  
  1.4       +1 -0      maven-components/maven-core/src/test/java/org/apache/maven/project/DefaultProjectDefaultsInjectorTest.java
  
  Index: DefaultProjectDefaultsInjectorTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/DefaultProjectDefaultsInjectorTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultProjectDefaultsInjectorTest.java	3 Feb 2005 09:10:02 -0000	1.3
  +++ DefaultProjectDefaultsInjectorTest.java	23 Feb 2005 01:59:34 -0000	1.4
  @@ -20,6 +20,7 @@
   import org.apache.maven.model.Dependency;
   import org.apache.maven.model.DependencyManagement;
   import org.apache.maven.model.Model;
  +import org.apache.maven.project.injection.DefaultProjectDefaultsInjector;
   
   import java.util.List;
   import java.util.Properties;
  
  
  

Mime
View raw message