incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r544877 - in /incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl: ArtifactContextImpl.java AssemblyResolverImpl.java
Date Wed, 06 Jun 2007 16:30:04 GMT
Author: sisbell
Date: Wed Jun  6 09:30:02 2007
New Revision: 544877

URL: http://svn.apache.org/viewvc?view=rev&rev=544877
Log:
Fixed the issue with 0KB downloads in JIRA: NMAVEN-75. Needed to explicitly copy the snaphot
file to a file without a version. The ArtifactResolver handled this correctly for release
version but not snapshots.

Modified:
    incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java
    incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java

Modified: incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java?view=diff&rev=544877&r1=544876&r2=544877
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactContextImpl.java
Wed Jun  6 09:30:02 2007
@@ -287,7 +287,6 @@
                 map.put( artifactHandler.getPackaging(), artifactHandler );
             }
         }
-
         artifactHandlerManager.addHandlers( map );
     }
 

Modified: incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java?view=diff&rev=544877&r1=544876&r2=544877
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/AssemblyResolverImpl.java
Wed Jun  6 09:30:02 2007
@@ -31,17 +31,21 @@
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Dependency;
 
 import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.util.Set;
 import java.util.HashSet;
 import java.util.List;
 
 import java.io.File;
+import java.io.IOException;
 
 /**
  * Provides a way to resolve transitive assemblies that do not have versions within their
file name.
@@ -126,28 +130,55 @@
                 artifactDependencies.add( artifact );
             }
         }
+        ArtifactRepository artifactRepository = new DefaultArtifactRepository( "local", "file://"
+
+            localArtifactRepository.getBasedir(), new DefaultRepositoryLayout() );
 
         ArtifactResolutionResult result = resolver.resolveTransitively( artifactDependencies,
sourceArtifact,
-                                                                        localArtifactRepository,
-                                                                        remoteArtifactRepositories,
metadata,
-                                                                        gacFilter );
+                                                                        artifactRepository,
remoteArtifactRepositories,
+                                                                        metadata, gacFilter
);
         Set<Artifact> resolvedDependencies = result.getArtifacts();
         AssemblyRepositoryLayout layout = new AssemblyRepositoryLayout();
-        if ( addResolvedDependenciesToProject )
+        for ( Artifact artifact : resolvedDependencies )
         {
-            for ( Artifact artifact : resolvedDependencies )
+            File originalFileWithVersion = artifact.getFile();
+            if ( artifact.isSnapshot() )
+            {
+                artifact.setVersion( artifact.getBaseVersion() );
+            }
+            File targetFileWithoutVersion =
+                new File( localArtifactRepository.getBasedir() + "/" + layout.pathOf( artifact
) );
+            if ( originalFileWithVersion.lastModified() > targetFileWithoutVersion.lastModified()
)
             {
-                File originalFileWithVersion = artifact.getFile();
-                File targetFileWithoutVersion = new File( localArtifactRepository + "/" +
layout.pathOf( artifact ) );
-                //  logger.info( "Original = " + originalFileWithVersion.getAbsolutePath()
+ ", Target = " +
-                //      targetFileWithoutVersion.getAbsolutePath() );
-                originalFileWithVersion.renameTo( targetFileWithoutVersion );
-                if ( targetFileWithoutVersion.exists() )
+                logger.debug( "Original = " + originalFileWithVersion.getAbsolutePath() +
", Target = " +
+                    targetFileWithoutVersion.getAbsolutePath() );
+                try
+                {
+                    FileUtils.copyFile( originalFileWithVersion, targetFileWithoutVersion
);
+                }
+                catch ( IOException e )
                 {
-                    artifact.setFile( targetFileWithoutVersion.getAbsoluteFile() );
+                    e.printStackTrace();
                 }
             }
 
+            /*
+            if ( !originalFileWithVersion.renameTo( targetFileWithoutVersion ) )
+            {
+                throw new ArtifactResolutionException( "NMAVEN-000-000: Failed to rename
artifact", artifact );
+            }
+            */
+            if ( originalFileWithVersion.length() != 0 && targetFileWithoutVersion.length()
== 0 )
+            {
+                throw new ArtifactResolutionException( "NMAVEN-000-000: Artifact is corrupted:",
artifact );
+            }
+
+            if ( targetFileWithoutVersion.exists() )
+            {
+                artifact.setFile( targetFileWithoutVersion.getAbsoluteFile() );
+            }
+        }
+        if ( addResolvedDependenciesToProject )
+        {
             resolvedDependencies.addAll( gacDependencies );
             project.setDependencyArtifacts( resolvedDependencies );
         }



Mime
View raw message