maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r543255 - /maven/shared/trunk/maven-repository-builder/src/main/java/org/apache/maven/shared/repository/DefaultRepositoryAssembler.java
Date Thu, 31 May 2007 20:57:45 GMT
Author: jdcasey
Date: Thu May 31 13:57:44 2007
New Revision: 543255

URL: http://svn.apache.org/viewvc?view=rev&rev=543255
Log:
[MASSEMBLY-210] Including the ancestry of the current project in the repository.

Modified:
    maven/shared/trunk/maven-repository-builder/src/main/java/org/apache/maven/shared/repository/DefaultRepositoryAssembler.java

Modified: maven/shared/trunk/maven-repository-builder/src/main/java/org/apache/maven/shared/repository/DefaultRepositoryAssembler.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-repository-builder/src/main/java/org/apache/maven/shared/repository/DefaultRepositoryAssembler.java?view=diff&rev=543255&r1=543254&r2=543255
==============================================================================
--- maven/shared/trunk/maven-repository-builder/src/main/java/org/apache/maven/shared/repository/DefaultRepositoryAssembler.java
(original)
+++ maven/shared/trunk/maven-repository-builder/src/main/java/org/apache/maven/shared/repository/DefaultRepositoryAssembler.java
Thu May 31 13:57:44 2007
@@ -183,6 +183,9 @@
         {
             assembleRepositoryMetadata( result, filter, centralRepository, targetRepository
);
         }
+
+        addPomWithAncestry( project.getArtifact(), project.getRemoteArtifactRepositories(),
localRepository,
+                            targetRepository, groupVersionAlignments );
     }
 
     private ArtifactFilter buildRepositoryFilter( RepositoryInfo repository, MavenProject
project )
@@ -276,38 +279,7 @@
 
                     writeChecksums( targetFile );
 
-                    if ( !"pom".equals( a.getType() ) )
-                    {
-                        a = artifactFactory.createProjectArtifact( a.getGroupId(), a.getArtifactId(),
a.getVersion() );
-
-                        MavenProject p = projectBuilder.buildFromRepository( a,
-                                                                             project.getRemoteArtifactRepositories(),
-                                                                             localRepository
);
-
-                        do
-                        {
-                            a = artifactFactory.createProjectArtifact( p.getGroupId(), p.getArtifactId(),
p
-                                .getVersion() );
-
-                            setAlignment( a, groupVersionAlignments );
-
-                            File sourceFile = new File( localRepository.getBasedir(), localRepository.pathOf(
a ) );
-
-                            if ( !sourceFile.exists() )
-                            {
-                                break;
-                            }
-
-                            targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf(
a ) );
-
-                            FileUtils.copyFile( sourceFile, targetFile );
-
-                            writeChecksums( targetFile );
-
-                            p = p.getParent();
-                        }
-                        while ( p != null );
-                    }
+                    addPomWithAncestry( a, project.getRemoteArtifactRepositories(), localRepository,
targetRepository, groupVersionAlignments );
                 }
             }
         }
@@ -323,9 +295,66 @@
         {
             throw new RepositoryAssemblyException( "Error writing artifact metdata.", e );
         }
-        catch ( ProjectBuildingException e )
+    }
+
+    private void addPomWithAncestry( Artifact artifact, List remoteArtifactRepositories,
+                                     ArtifactRepository localRepository, ArtifactRepository
targetRepository,
+                                     Map groupVersionAlignments )
+        throws RepositoryAssemblyException
+    {
+        if ( !"pom".equals( artifact.getType() ) )
         {
-            throw new RepositoryAssemblyException( "Error reading POM.", e );
+            artifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion() );
+
+            MavenProject p;
+            try
+            {
+                p = projectBuilder.buildFromRepository( artifact,
+                                                                     remoteArtifactRepositories,
+                                                                     localRepository );
+            }
+            catch ( ProjectBuildingException e )
+            {
+                throw new RepositoryAssemblyException( "Error reading POM: " + artifact.getId(),
e );
+            }
+
+            do
+            {
+                artifact = artifactFactory.createProjectArtifact( p.getGroupId(), p.getArtifactId(),
p
+                    .getVersion() );
+
+                setAlignment( artifact, groupVersionAlignments );
+
+                File sourceFile = new File( localRepository.getBasedir(), localRepository.pathOf(
artifact ) );
+
+                if ( !sourceFile.exists() )
+                {
+                    break;
+                }
+
+                File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf(
artifact ) );
+
+                try
+                {
+                    FileUtils.copyFile( sourceFile, targetFile );
+                }
+                catch ( IOException e )
+                {
+                    throw new RepositoryAssemblyException( "Error writing POM metdata: "
+ artifact.getId(), e );
+                }
+
+                try
+                {
+                    writeChecksums( targetFile );
+                }
+                catch ( IOException e )
+                {
+                    throw new RepositoryAssemblyException( "Error writing checksums for POM:
" + artifact.getId(), e );
+                }
+
+                p = p.getParent();
+            }
+            while ( p != null );
         }
     }
 



Mime
View raw message