You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2004/04/02 22:41:22 UTC

cvs commit: maven-components/maven-project/src/main/java/org/apache/maven/project DefaultModelInheritanceAssembler.java ModelInheritanceAssembler.java DefaultMavenProjectBuilder.java

jvanzyl     2004/04/02 12:41:21

  Modified:    maven-project/src/main/java/org/apache/maven/project
                        DefaultMavenProjectBuilder.java
  Added:       maven-project/src/main/java/org/apache/maven/project
                        DefaultModelInheritanceAssembler.java
                        ModelInheritanceAssembler.java
  Log:
  o pushing out the inheritance tool into a separate component so we can
    experiment easily.
  
  Revision  Changes    Path
  1.7       +7 -154    maven-components/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
  
  Index: DefaultMavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultMavenProjectBuilder.java	22 Mar 2004 00:11:15 -0000	1.6
  +++ DefaultMavenProjectBuilder.java	2 Apr 2004 20:41:21 -0000	1.7
  @@ -16,7 +16,7 @@
    * limitations under the License.
    */
   
  -import org.apache.maven.artifact.factory.MavenArtifactory;
  +import org.apache.maven.artifact.factory.MavenArtifactFactory;
   import org.apache.maven.model.Dependency;
   import org.apache.maven.model.Model;
   import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
  @@ -49,7 +49,9 @@
   
       private MavenXpp3Reader modelReader;
   
  -    private MavenArtifactory artifactory;
  +    private MavenArtifactFactory artifactory;
  +
  +    private ModelInheritanceAssembler modelInheritanceAssembler;
   
       public MavenProject build( File project )
           throws Exception
  @@ -64,11 +66,12 @@
   
           MavenProject project = assembleLineage( projectDescriptor, useParentPom, lineage );
   
  -        setupModelInheritance( ( (MavenProject) lineage.get( 0 ) ).getModel(), getSuperModel() );
  +        modelInheritanceAssembler.assembleModelInheritance( ( (MavenProject) lineage.get( 0 ) ).getModel(), getSuperModel() );
   
           for ( int i = 1; i < lineage.size(); i++ )
           {
  -            setupModelInheritance( ( (MavenProject) lineage.get( i ) ).getModel(), ( (MavenProject) lineage.get( i - 1 ) ).getModel() );
  +            modelInheritanceAssembler.assembleModelInheritance(
  +                ( (MavenProject) lineage.get( i ) ).getModel(), ( (MavenProject) lineage.get( i - 1 ) ).getModel() );
           }
   
           project.setInterpolatedModel( interpolateModel( project.getModel(), project.getProperties() ) );
  @@ -147,156 +150,6 @@
                   project.setProperty( "maven.final.name", MavenProject.standardToLegacyId( project.getId() ) + "-" + project.getVersion() );
               }
           }
  -    }
  -
  -    private void setupModelInheritance( Model child, Model parent )
  -    {
  -        // Pom version
  -        if ( child.getModelVersion() == null )
  -        {
  -            child.setModelVersion( parent.getModelVersion() );
  -        }
  -
  -        // Group id
  -        if ( child.getGroupId() == null )
  -        {
  -            child.setGroupId( parent.getGroupId() );
  -        }
  -
  -        // artifactId
  -        if ( child.getArtifactId() == null )
  -        {
  -            child.setArtifactId( parent.getArtifactId() );
  -        }
  -
  -        // name
  -        if ( child.getName() == null )
  -        {
  -            child.setName( parent.getName() );
  -        }
  -
  -        // currentVersion
  -        if ( child.getVersion() == null )
  -        {
  -            child.setVersion( parent.getVersion() );
  -        }
  -
  -        // inceptionYear
  -        if ( child.getInceptionYear() == null )
  -        {
  -            child.setInceptionYear( parent.getInceptionYear() );
  -        }
  -
  -        // Name
  -        if ( child.getPackage() == null )
  -        {
  -            child.setPackage( parent.getPackage() );
  -        }
  -
  -        // url
  -        if ( child.getUrl() == null )
  -        {
  -            child.setUrl( parent.getUrl() );
  -        }
  -
  -        // siteAddress
  -        if ( child.getSiteAddress() == null )
  -        {
  -            child.setSiteAddress( parent.getSiteAddress() );
  -        }
  -
  -        // siteDirectory
  -        if ( child.getSiteDirectory() == null )
  -        {
  -            child.setSiteDirectory( parent.getSiteDirectory() );
  -        }
  -
  -        // distributionDirectory
  -        if ( child.getDistributionDirectory() == null )
  -        {
  -            child.setDistributionDirectory( parent.getDistributionDirectory() );
  -        }
  -
  -        // issueTrackingUrl
  -        if ( child.getIssueTrackingUrl() == null )
  -        {
  -            child.setIssueTrackingUrl( parent.getIssueTrackingUrl() );
  -        }
  -
  -        // Short description
  -        if ( child.getShortDescription() == null )
  -        {
  -            child.setShortDescription( parent.getShortDescription() );
  -        }
  -
  -        // Short description
  -        if ( child.getDescription() == null )
  -        {
  -            child.setDescription( parent.getDescription() );
  -        }
  -
  -        // Organization
  -        if ( child.getOrganization() == null )
  -        {
  -            child.setOrganization( parent.getOrganization() );
  -        }
  -
  -        // Build
  -        if ( child.getRepository() == null )
  -        {
  -            child.setRepository( parent.getRepository() );
  -        }
  -
  -        // developers
  -        if ( child.getDevelopers().size() == 0 )
  -        {
  -            child.setDevelopers( parent.getDevelopers() );
  -        }
  -
  -        // developers
  -        if ( child.getContributors().size() == 0 )
  -        {
  -            child.setContributors( parent.getContributors() );
  -        }
  -
  -        // mailingLists
  -        if ( child.getMailingLists().size() == 0 )
  -        {
  -            child.setMailingLists( parent.getMailingLists() );
  -        }
  -
  -        // versions
  -        if ( child.getVersions().size() == 0 )
  -        {
  -            child.setVersions( parent.getVersions() );
  -        }
  -
  -        // branches
  -        if ( child.getBranches().size() == 0 )
  -        {
  -            child.setBranches( parent.getBranches() );
  -        }
  -
  -        // dependencies
  -        if ( child.getDependencies().size() == 0 )
  -        {
  -            child.setDependencies( parent.getDependencies() );
  -        }
  -
  -        // reports
  -        if ( child.getReports().size() == 0 )
  -        {
  -            child.setReports( parent.getReports() );
  -        }
  -
  -        // Build
  -        if ( child.getBuild() == null )
  -        {
  -            child.setBuild( parent.getBuild() );
  -        }
  -
  -        // Dependencies :: aggregate
  -        //child.addParentDependencies( parent.getDependencies() );
       }
   
       Map createProjectProperties( File descriptorDirectory )
  
  
  
  1.1                  maven-components/maven-project/src/main/java/org/apache/maven/project/DefaultModelInheritanceAssembler.java
  
  Index: DefaultModelInheritanceAssembler.java
  ===================================================================
  package org.apache.maven.project;
  
  import org.apache.maven.model.Model;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: DefaultModelInheritanceAssembler.java,v 1.1 2004/04/02 20:41:21 jvanzyl Exp $
   */
  public class DefaultModelInheritanceAssembler
      implements ModelInheritanceAssembler
  {
      public void assembleModelInheritance( Model child, Model parent )
      {
          // Pom version
          if ( child.getModelVersion() == null )
          {
              child.setModelVersion( parent.getModelVersion() );
          }
  
          // Group id
          if ( child.getGroupId() == null )
          {
              child.setGroupId( parent.getGroupId() );
          }
  
          // artifactId
          if ( child.getArtifactId() == null )
          {
              child.setArtifactId( parent.getArtifactId() );
          }
  
          // name
          if ( child.getName() == null )
          {
              child.setName( parent.getName() );
          }
  
          // currentVersion
          if ( child.getVersion() == null )
          {
              child.setVersion( parent.getVersion() );
          }
  
          // inceptionYear
          if ( child.getInceptionYear() == null )
          {
              child.setInceptionYear( parent.getInceptionYear() );
          }
  
          // Name
          if ( child.getPackage() == null )
          {
              child.setPackage( parent.getPackage() );
          }
  
          // url
          if ( child.getUrl() == null )
          {
              child.setUrl( parent.getUrl() );
          }
  
          // siteAddress
          if ( child.getSiteAddress() == null )
          {
              child.setSiteAddress( parent.getSiteAddress() );
          }
  
          // siteDirectory
          if ( child.getSiteDirectory() == null )
          {
              child.setSiteDirectory( parent.getSiteDirectory() );
          }
  
          // distributionDirectory
          if ( child.getDistributionDirectory() == null )
          {
              child.setDistributionDirectory( parent.getDistributionDirectory() );
          }
  
          // issueTrackingUrl
          if ( child.getIssueTrackingUrl() == null )
          {
              child.setIssueTrackingUrl( parent.getIssueTrackingUrl() );
          }
  
          // Short description
          if ( child.getShortDescription() == null )
          {
              child.setShortDescription( parent.getShortDescription() );
          }
  
          // Short description
          if ( child.getDescription() == null )
          {
              child.setDescription( parent.getDescription() );
          }
  
          // Organization
          if ( child.getOrganization() == null )
          {
              child.setOrganization( parent.getOrganization() );
          }
  
          // Build
          if ( child.getRepository() == null )
          {
              child.setRepository( parent.getRepository() );
          }
  
          // developers
          if ( child.getDevelopers().size() == 0 )
          {
              child.setDevelopers( parent.getDevelopers() );
          }
  
          // developers
          if ( child.getContributors().size() == 0 )
          {
              child.setContributors( parent.getContributors() );
          }
  
          // mailingLists
          if ( child.getMailingLists().size() == 0 )
          {
              child.setMailingLists( parent.getMailingLists() );
          }
  
          // versions
          if ( child.getVersions().size() == 0 )
          {
              child.setVersions( parent.getVersions() );
          }
  
          // branches
          if ( child.getBranches().size() == 0 )
          {
              child.setBranches( parent.getBranches() );
          }
  
          // dependencies
          if ( child.getDependencies().size() == 0 )
          {
              child.setDependencies( parent.getDependencies() );
          }
  
          // reports
          if ( child.getReports().size() == 0 )
          {
              child.setReports( parent.getReports() );
          }
  
          // Build
          if ( child.getBuild() == null )
          {
              child.setBuild( parent.getBuild() );
          }
  
          // Dependencies :: aggregate
          //child.addParentDependencies( parent.getDependencies() );
      }
  }
  
  
  
  1.1                  maven-components/maven-project/src/main/java/org/apache/maven/project/ModelInheritanceAssembler.java
  
  Index: ModelInheritanceAssembler.java
  ===================================================================
  package org.apache.maven.project;
  
  import org.apache.maven.model.Model;
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: ModelInheritanceAssembler.java,v 1.1 2004/04/02 20:41:21 jvanzyl Exp $
   */
  public interface ModelInheritanceAssembler
  {
      String ROLE = ModelInheritanceAssembler.class.getName();
  
      void assembleModelInheritance( Model child, Model parent );
  }
  
  
  

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