You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Brett Porter <br...@apache.org> on 2007/02/11 23:54:12 UTC
Re: svn commit: r506109 - /maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
This seems to have been more than just that revision, since it's
reverted the license header too.
On 12/02/2007, at 6:53 AM, jvanzyl@apache.org wrote:
> Author: jvanzyl
> Date: Sun Feb 11 11:53:21 2007
> New Revision: 506109
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=506109
> Log:
> MNG-2820 from trunk rev 506108
>
> Modified:
> maven/components/branches/maven-2.0.x/maven-project/src/main/
> java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
>
> Modified: maven/components/branches/maven-2.0.x/maven-project/src/
> main/java/org/apache/maven/project/artifact/
> ProjectArtifactMetadata.java
> URL: http://svn.apache.org/viewvc/maven/components/branches/
> maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/
> artifact/ProjectArtifactMetadata.java?
> view=diff&rev=506109&r1=506108&r2=506109
> ======================================================================
> ========
> --- maven/components/branches/maven-2.0.x/maven-project/src/main/
> java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
> (original)
> +++ maven/components/branches/maven-2.0.x/maven-project/src/main/
> java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
> Sun Feb 11 11:53:21 2007
> @@ -1,44 +1,36 @@
> package org.apache.maven.project.artifact;
>
> /*
> - * Licensed to the Apache Software Foundation (ASF) under one
> - * or more contributor license agreements. See the NOTICE file
> - * distributed with this work for additional information
> - * regarding copyright ownership. The ASF licenses this file
> - * to you 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
> + * Copyright 2001-2005 The Apache Software Foundation.
> *
> - * http://www.apache.org/licenses/LICENSE-2.0
> + * 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
> *
> - * 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.
> + * 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.ArtifactStatus;
> import org.apache.maven.artifact.metadata.AbstractArtifactMetadata;
> import org.apache.maven.artifact.metadata.ArtifactMetadata;
> import org.apache.maven.artifact.repository.ArtifactRepository;
> import
> org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreE
> xception;
> -import org.apache.maven.model.DistributionManagement;
> -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 org.codehaus.plexus.util.xml.pull.XmlPullParserException;
> +import org.codehaus.plexus.util.FileUtils;
>
> import java.io.File;
> import java.io.FileNotFoundException;
> import java.io.FileReader;
> import java.io.FileWriter;
> import java.io.IOException;
> -import java.io.StringReader;
> -import java.io.StringWriter;
> +import java.io.Reader;
> +import java.io.Writer;
>
> /**
> * Attach a POM to an artifact.
> @@ -56,7 +48,8 @@
> this( artifact, null );
> }
>
> - public ProjectArtifactMetadata( Artifact artifact, File file )
> + public ProjectArtifactMetadata( Artifact artifact,
> + File file )
> {
> super( artifact );
> this.file = file;
> @@ -77,42 +70,31 @@
> return getArtifactId() + "-" + artifact.getVersion() +
> ".pom";
> }
>
> - public void storeInLocalRepository( ArtifactRepository
> localRepository, ArtifactRepository remoteRepository )
> + public void storeInLocalRepository( ArtifactRepository
> localRepository,
> + ArtifactRepository
> remoteRepository )
> throws RepositoryMetadataStoreException
> {
> File destination = new File( localRepository.getBasedir(),
>
> localRepository.pathOfLocalRepositoryMetadata( this,
> remoteRepository ) );
>
> - destination.getParentFile().mkdirs();
> + //
> ----------------------------------------------------------------------
> ------
> + // I'm fully aware that the file could just be moved using
> File.rename but
> + // there are bugs in various JVM that have problems doing
> this across
> + // different filesystem. So we'll incur the small hit to
> actually copy
> + // here and be safe. jvz.
> + //
> ----------------------------------------------------------------------
> ------
> +
> + Reader reader = null;
> +
> + Writer writer = null;
>
> - FileReader reader = null;
> - FileWriter writer = null;
> try
> {
> reader = new FileReader( file );
> - StringWriter sWriter = new StringWriter();
> - IOUtil.copy( reader, sWriter );
> -
> - String modelSrc = sWriter.toString().replaceAll( "\\$\\
> {(pom\\.|project\\.)?version\\}", artifact.getBaseVersion() );
> -
> - StringReader sReader = new StringReader( modelSrc );
> -
> - writer = new FileWriter( destination );
>
> - MavenXpp3Reader modelReader = new MavenXpp3Reader();
> - Model model = modelReader.read( sReader, false );
> - model.setVersion( artifact.getVersion() );
> -
> - DistributionManagement distributionManagement =
> model.getDistributionManagement();
> - if ( distributionManagement == null )
> - {
> - distributionManagement = new DistributionManagement
> ();
> - model.setDistributionManagement
> ( distributionManagement );
> - }
> - distributionManagement.setStatus
> ( ArtifactStatus.DEPLOYED.toString() );
> + writer = new FileWriter( destination );
>
> - MavenXpp3Writer modelWriter = new MavenXpp3Writer();
> - modelWriter.write( writer, model );
> + IOUtil.copy( reader, writer );
> }
> catch ( FileNotFoundException e )
> {
> @@ -122,13 +104,10 @@
> {
> throw new RepositoryMetadataStoreException( "Error
> rewriting POM", e );
> }
> - catch ( XmlPullParserException e )
> - {
> - throw new RepositoryMetadataStoreException( "Error
> rewriting POM", e );
> - }
> finally
> {
> IOUtil.close( reader );
> +
> IOUtil.close( writer );
> }
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org