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-artifact/src/main/java/org/apache/maven/artifact/metadata ModelMetadata.java
Date Thu, 24 Mar 2005 12:22:05 GMT
brett       2005/03/24 04:22:05

  Modified:    maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy
                        DeployMojo.java
               maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install
                        InstallMojo.java
  Added:       maven-core/src/main/java/org/apache/maven/artifact/metadata
                        MavenMetadata.java
  Removed:     maven-artifact/src/main/java/org/apache/maven/artifact/metadata
                        ModelMetadata.java
  Log:
  rewrite POM with new version on deployment
  
  Revision  Changes    Path
  1.9       +3 -3      maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
  
  Index: DeployMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DeployMojo.java	24 Mar 2005 11:57:47 -0000	1.8
  +++ DeployMojo.java	24 Mar 2005 12:22:04 -0000	1.9
  @@ -21,7 +21,7 @@
   import org.apache.maven.artifact.deployer.ArtifactDeployer;
   import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
   import org.apache.maven.artifact.metadata.ArtifactMetadata;
  -import org.apache.maven.artifact.metadata.ModelMetadata;
  +import org.apache.maven.artifact.metadata.MavenMetadata;
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.plugin.AbstractPlugin;
   import org.apache.maven.plugin.PluginExecutionException;
  @@ -93,7 +93,7 @@
           File pom = new File( project.getFile().getParentFile(), "pom.xml" );
           if ( !isPomArtifact )
           {
  -            ArtifactMetadata metadata = new ModelMetadata( artifact, pom );
  +            ArtifactMetadata metadata = new MavenMetadata( artifact, pom );
               artifact.addMetadata( metadata );
           }
   
  
  
  
  1.14      +3 -3      maven-components/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
  
  Index: InstallMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- InstallMojo.java	24 Mar 2005 11:57:47 -0000	1.13
  +++ InstallMojo.java	24 Mar 2005 12:22:04 -0000	1.14
  @@ -21,7 +21,7 @@
   import org.apache.maven.artifact.installer.ArtifactInstallationException;
   import org.apache.maven.artifact.installer.ArtifactInstaller;
   import org.apache.maven.artifact.metadata.ArtifactMetadata;
  -import org.apache.maven.artifact.metadata.ModelMetadata;
  +import org.apache.maven.artifact.metadata.MavenMetadata;
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.plugin.AbstractPlugin;
   import org.apache.maven.plugin.PluginExecutionException;
  @@ -72,7 +72,7 @@
           File pom = new File( project.getFile().getParentFile(), "pom.xml" );
           if ( !isPomArtifact )
           {
  -            ArtifactMetadata metadata = new ModelMetadata( artifact, pom );
  +            ArtifactMetadata metadata = new MavenMetadata( artifact, pom );
               artifact.addMetadata( metadata );
           }
   
  
  
  
  1.1                  maven-components/maven-core/src/main/java/org/apache/maven/artifact/metadata/MavenMetadata.java
  
  Index: MavenMetadata.java
  ===================================================================
  package org.apache.maven.artifact.metadata;
  
  /*
   * 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.artifact.Artifact;
  import org.apache.maven.artifact.manager.WagonManager;
  import org.apache.maven.artifact.repository.ArtifactRepository;
  import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
  import org.apache.maven.model.Model;
  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
  import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
  import org.codehaus.plexus.util.IOUtil;
  
  import java.io.File;
  import java.io.FileReader;
  import java.io.FileWriter;
  
  /**
   * Attach a POM to an artifact.
   *
   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
   * @version $Id: MavenMetadata.java,v 1.1 2005/03/24 12:22:04 brett Exp $
   */
  public class MavenMetadata
      extends AbstractArtifactMetadata
  {
      private final File file;
  
      public MavenMetadata( Artifact artifact, File file )
      {
          super( artifact, "pom" );
          this.file = file;
      }
  
      public void storeInLocalRepository( ArtifactRepository localRepository )
          throws ArtifactMetadataRetrievalException
      {
          File destination;
          try
          {
              destination = new File( localRepository.getBasedir(), localRepository.pathOfMetadata(
this ) );
          }
          catch ( ArtifactPathFormatException e )
          {
              throw new ArtifactMetadataRetrievalException( "Unable to install POM", e );
          }
  
          FileReader reader = null;
          FileWriter writer = null;
          try
          {
              reader = new FileReader( file );
              writer = new FileWriter( destination );
  
              MavenXpp3Reader modelReader = new MavenXpp3Reader();
              Model model = modelReader.read( reader );
              model.setVersion( getArtifact().getVersion() );
  
              MavenXpp3Writer modelWriter = new MavenXpp3Writer();
              modelWriter.write( writer, model );
          }
          catch ( Exception e )
          {
              throw new ArtifactMetadataRetrievalException( "Error rewriting POM", e );
          }
          finally
          {
              IOUtil.close( reader );
              IOUtil.close( writer );
          }
      }
  
      public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager
wagonManager )
      {
          // not used - TODO: again indicates bad design?
      }
  }
  
  
  

Mime
View raw message