Author: hboutemy
Date: Fri Mar 26 23:00:15 2010
New Revision: 928093

URL: http://svn.apache.org/viewvc?rev=928093&view=rev
Log:
added exception chaining

Modified:
    
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
    
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/WritePomTask.java
    
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntBuildWriter.java
    
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntTaskModified.java
    
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntUtil.java

Modified: 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=928093&r1=928092&r2=928093&view=diff
==============================================================================
--- 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
 (original)
+++ 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
 Fri Mar 26 23:00:15 2010
@@ -62,9 +62,9 @@ import java.util.Set;
 public class DependenciesTask
     extends AbstractArtifactWithRepositoryTask
 {
-    
+
     public static final String DEFAULT_ANT_BUILD_FILE = 
"target/build-dependencies.xml";
-    
+
     private List dependencies = new ArrayList();
 
     /**
@@ -81,12 +81,12 @@ public class DependenciesTask
      * The id of the fileset object containing all resolved source jars for 
the list of dependencies.
      */
     private String sourcesFilesetId;
-    
+
     /**
      * The id of the fileset object containing all resolved javadoc jars for 
the list of dependencies.
      */
     private String javadocFilesetId;
-    
+
     /**
      * The id of the object containing a list of all artifact versions.
      * This is used for things like removing the version from the dependency 
filenames.
@@ -124,18 +124,18 @@ public class DependenciesTask
      */
     protected void doExecute()
     {
-        
+
         if ( useScope != null && scopes != null )
         {
             throw new BuildException( "You cannot specify both useScope and 
scopes in the dependencies task." );
         }
-                
+
         if ( getPom() != null && !this.dependencies.isEmpty() )
         {
             throw new BuildException( "You cannot specify both dependencies 
and a pom in the dependencies task" );
         }
-        
-        // Try to load dependency refs from an exsiting Ant cache file
+
+        // Try to load dependency refs from an existing Ant cache file
         if ( isCacheDependencyRefs() )
         {
             if ( getDependencyRefsBuildFile() == null )
@@ -148,7 +148,7 @@ public class DependenciesTask
                 return;
             }
         }
-        
+
         ArtifactRepository localRepo = createLocalArtifactRepository();
         log( "Using local repository: " + localRepo.getBasedir(), 
Project.MSG_VERBOSE );
 
@@ -177,15 +177,14 @@ public class DependenciesTask
         log( "Resolving dependencies...", Project.MSG_VERBOSE );
 
         ArtifactResolutionResult result;
-        Set artifacts;
 
         List remoteArtifactRepositories = createRemoteArtifactRepositories( 
pom.getRepositories() );
 
         try
         {
-            artifacts = MavenMetadataSource.createArtifacts( artifactFactory, 
dependencies, null, null, null );
+            Set artifacts = MavenMetadataSource.createArtifacts( 
artifactFactory, dependencies, null, null, null );
 
-            Artifact pomArtifact = artifactFactory.createBuildArtifact( 
pom.getGroupId(), pom.getArtifactId(), 
+            Artifact pomArtifact = artifactFactory.createBuildArtifact( 
pom.getGroupId(), pom.getArtifactId(),
                 pom.getVersion(), pom.getPackaging() );
 
             List listeners = Collections.singletonList( new 
AntResolutionListener( getProject() ) );
@@ -240,9 +239,9 @@ public class DependenciesTask
         FileSet javadocsFileSet = createFileSet();
 
         Path dependencyPath = new Path( getProject() );
-        
+
         Set versions = new HashSet();
-        
+
         for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
         {
             Artifact artifact = (Artifact) i.next();
@@ -268,20 +267,20 @@ public class DependenciesTask
         defineFilesetReference( filesetId, dependencyFileSet );
 
         defineFilesetReference( sourcesFilesetId, sourcesFileSet );
-        
+
         defineFilesetReference( javadocFilesetId, javadocsFileSet );
-        
+
         if ( pathId != null )
         {
             getProject().addReference( pathId, dependencyPath );
         }
-        
+
         if ( versionsId != null )
         {
             String versionsValue = StringUtils.join( versions.iterator(), 
File.pathSeparator );
             getProject().setNewProperty( versionsId, versionsValue );
         }
-        
+
         // Write the dependency information to an Ant build file.
         if ( getDependencyRefsBuildFile() != null || 
this.isCacheDependencyRefs() )
         {
@@ -292,12 +291,12 @@ public class DependenciesTask
             log( "Building ant file: " + getDependencyRefsBuildFile());
             AntBuildWriter antBuildWriter = new AntBuildWriter();
             File antBuildFile = new File( getProject().getBaseDir(), 
getDependencyRefsBuildFile() );
-            try 
+            try
             {
                 antBuildWriter.openAntBuild( antBuildFile, 
"maven-dependencies", "init-dependencies" );
                 antBuildWriter.openTarget( "init-dependencies" );
                 antBuildWriter.writeEcho( "Loading dependency paths from file: 
" + antBuildFile.getAbsolutePath() );
-                
+
                 Iterator i = result.getArtifacts().iterator();
                 while (  i.hasNext() )
                 {
@@ -307,13 +306,13 @@ public class DependenciesTask
                     FileSet singleArtifactFileSet = 
(FileSet)getProject().getReference( conflictId );
                     antBuildWriter.writeFileSet( singleArtifactFileSet, 
conflictId );
                 }
-                
+
                 if ( pathId != null )
                 {
                     Path thePath = (Path)getProject().getReference( pathId );
                     antBuildWriter.writePath( thePath, pathId );
                 }
-                
+
                 if ( filesetId != null )
                 {
                     antBuildWriter.writeFileSet( dependencyFileSet, filesetId 
);
@@ -326,10 +325,10 @@ public class DependenciesTask
                 {
                     antBuildWriter.writeFileSet( sourcesFileSet, 
javadocFilesetId );
                 }
-                
+
                 String versionsList = getProject().getProperty( versionsId );
                 antBuildWriter.writeProperty( versionsId, versionsList );
-                
+
                 antBuildWriter.closeTarget();
                 antBuildWriter.closeAntBuild();
             }
@@ -339,10 +338,10 @@ public class DependenciesTask
             }
         }
     }
-    
+
     /**
      * Check if the cache needs to be updated.
-     * 
+     *
      * @return true if the dependency refs were successfully loaded, false 
otherwise
      */
     private boolean checkCachedDependencies()
@@ -352,13 +351,13 @@ public class DependenciesTask
         {
             return false;
         }
-        
+
         File antBuildFile = new File( getProject().getProperty( "ant.file" ) );
         if ( antBuildFile.lastModified() > cacheBuildFile.lastModified() )
         {
             return false;
         }
-        
+
         Pom pom = getPom();
         if ( pom != null )
         {
@@ -368,33 +367,33 @@ public class DependenciesTask
                 return false;
             }
         }
-        
+
         return loadDependenciesFromAntBuildFile();
     }
-    
+
     /**
      * Load the dependency references from the generated ant build file.
-     * 
+     *
      * @return True if the dependency refs were successfully loaded.
      */
     private boolean loadDependenciesFromAntBuildFile()
     {
         Project currentAntProject = getProject();
-        
+
         // Run the ant build with the dependency refs
         AntTaskModified dependenciesAntBuild = new AntTaskModified();
         dependenciesAntBuild.setAntfile( getDependencyRefsBuildFile() );
         dependenciesAntBuild.setProject( currentAntProject );
         dependenciesAntBuild.execute();
-        
+
         // Copy the properties and refs to the current project
         Project cachedDepsProject = dependenciesAntBuild.getSavedNewProject();
         AntUtil.copyProperties( cachedDepsProject, currentAntProject );
         AntUtil.copyReferences( cachedDepsProject, currentAntProject );
-        
+
         return true;
     }
-        
+
     private FileSet createFileSet()
     {
         FileSet fileSet = new FileSet();
@@ -415,13 +414,13 @@ public class DependenciesTask
         }
     }
 
-    private void addArtifactToResult( ArtifactRepository localRepo, Artifact 
artifact, 
+    private void addArtifactToResult( ArtifactRepository localRepo, Artifact 
artifact,
                                       FileSet toFileSet )
     {
         addArtifactToResult( localRepo, artifact, toFileSet, null );
     }
-    
-    private void addArtifactToResult( ArtifactRepository localRepo, Artifact 
artifact, 
+
+    private void addArtifactToResult( ArtifactRepository localRepo, Artifact 
artifact,
                                       FileSet toFileSet, Path path )
     {
         String filename = localRepo.pathOf( artifact );
@@ -429,12 +428,12 @@ public class DependenciesTask
         toFileSet.createInclude().setName( filename );
 
         getProject().setProperty( artifact.getDependencyConflictId(), 
artifact.getFile().getAbsolutePath() );
-        
+
         FileSet artifactFileSet = new FileSet();
         artifactFileSet.setProject( getProject() );
         artifactFileSet.setFile( artifact.getFile() );
         getProject().addReference( artifact.getDependencyConflictId(), 
artifactFileSet );
-        
+
         if ( path != null )
         {
             path.addFileset( artifactFileSet );
@@ -533,7 +532,7 @@ public class DependenciesTask
     /**
      * Use the maven artifact filtering for a particular scope.  This
      * uses the standard maven ScopeArtifactFilter.
-     * 
+     *
      * @param useScope
      */
     public void setUseScope( String useScope )
@@ -553,7 +552,7 @@ public class DependenciesTask
 
     /**
      * Only include artifacts that fall under one of the specified scopes.
-     * 
+     *
      * @return
      */
     public void setScopes( String scopes )

Modified: 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/WritePomTask.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/WritePomTask.java?rev=928093&r1=928092&r2=928093&view=diff
==============================================================================
--- 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/WritePomTask.java
 (original)
+++ 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/WritePomTask.java
 Fri Mar 26 23:00:15 2010
@@ -32,7 +32,7 @@ import org.codehaus.plexus.util.WriterFa
 
 /**
  * Write a POM to a file.
- * 
+ *
  * @since 2.1.0
  */
 public class WritePomTask
@@ -41,7 +41,7 @@ public class WritePomTask
     private String pomRefId;
 
     private File file;
-    
+
     private boolean trim = true;
 
     public void execute()
@@ -51,11 +51,11 @@ public class WritePomTask
         Model model = pom.getModel();
         if ( trim )
         {
-            trimModel ( model );            
+            trimModel ( model );
         }
-        writeModel ( model, file );
+        writeModel( model, file );
     }
-    
+
     /**
      * Removes a lot of unnecessary information from the POM.
      * This includes the build section, reporting, repositories, etc.
@@ -74,7 +74,7 @@ public class WritePomTask
 
     /**
      * Write a POM model to a file
-     * 
+     *
      * @param model
      * @return
      * @throws MojoExecutionException

Modified: 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntBuildWriter.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntBuildWriter.java?rev=928093&r1=928092&r2=928093&view=diff
==============================================================================
--- 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntBuildWriter.java
 (original)
+++ 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntBuildWriter.java
 Fri Mar 26 23:00:15 2010
@@ -52,7 +52,7 @@ public class AntBuildWriter
 
     /**
      * Open an Ant build file for writing. Opens the file and prints the 
opening project tag.
-     * 
+     *
      * @param buildFile
      * @param name
      * @param defaultTarget
@@ -81,7 +81,7 @@ public class AntBuildWriter
 
     /**
      * Close the ant build writer
-     * 
+     *
      * @throws IOException
      */
     public void closeAntBuild()
@@ -97,7 +97,7 @@ public class AntBuildWriter
 
     /**
      * Open a target tag
-     * 
+     *
      * @param targetName
      * @throws IOException
      */
@@ -110,7 +110,7 @@ public class AntBuildWriter
 
     /**
      * Close a tag.
-     * 
+     *
      * @throws IOException
      */
     public void closeTarget()
@@ -121,7 +121,7 @@ public class AntBuildWriter
 
     /**
      * Write an Ant fileset
-     * 
+     *
      * @param fileSet
      * @param id
      */
@@ -153,7 +153,7 @@ public class AntBuildWriter
 
     /**
      * Write an ant property
-     * 
+     *
      * @param name
      * @param value
      */
@@ -168,8 +168,8 @@ public class AntBuildWriter
     }
 
     /**
-     * Write an Ant echo task 
-     * 
+     * Write an Ant echo task
+     *
      * @param message
      */
     public void writeEcho( String message )
@@ -183,7 +183,7 @@ public class AntBuildWriter
 
     /**
      * Write an Ant file list
-     * 
+     *
      * @param fileList
      * @param id
      */
@@ -206,7 +206,7 @@ public class AntBuildWriter
 
     /**
      * Write a path.
-     * 
+     *
      * @param path
      * @param pathId
      */

Modified: 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntTaskModified.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntTaskModified.java?rev=928093&r1=928092&r2=928093&view=diff
==============================================================================
--- 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntTaskModified.java
 (original)
+++ 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntTaskModified.java
 Fri Mar 26 23:00:15 2010
@@ -28,32 +28,32 @@ import org.apache.tools.ant.taskdefs.Ant
 /**
  * A modified version of the Ant task that allows access to the
  * new sub project.
- * 
+ *
  * @author pgier
  *
  */
 public class AntTaskModified extends Ant
 {
-    
+
     /**
-     * The Ant tasks sets newProject to null at the end of execute(), so 
+     * The Ant tasks sets newProject to null at the end of execute(), so
      * we need to save this object to a different place.
      */
     private Project savedNewProject;
-    
+
     public void init()
     {
         super.init();
         savedNewProject = saveNewProject();
     }
-    
+
     /**
      * This is a hack to get access to the private variable "newProject" in 
the Ant task. This should not be used.
      * Note: This may not work with later versions of Ant
-     * 
+     *
      * @return
      */
-    private Project saveNewProject( )
+    private Project saveNewProject()
     {
         try
         {
@@ -64,18 +64,18 @@ public class AntTaskModified extends Ant
         }
         catch ( Exception e )
         {
-            throw new BuildException( "Unable to load cache: " + e );
+            throw new BuildException( "Unable to load cache: " + e, e );
         }
     }
-    
+
     /**
      * Get the new Ant project created by this task.
-     * 
+     *
      * @return
      */
     public Project getSavedNewProject()
     {
         return savedNewProject;
     }
-    
+
 }

Modified: 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntUtil.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntUtil.java?rev=928093&r1=928092&r2=928093&view=diff
==============================================================================
--- 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntUtil.java
 (original)
+++ 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/util/AntUtil.java
 Fri Mar 26 23:00:15 2010
@@ -33,7 +33,7 @@ public class AntUtil
     /**
      * Copies all properties from the given project to the new project - 
omitting those that have already been set in the
      * new project as well as properties named basedir or ant.file.
-     * 
+     *
      * @param fromProject copy from
      * @param toProject copy to
      */
@@ -41,11 +41,11 @@ public class AntUtil
     {
         copyProperties( fromProject.getProperties(), toProject );
     }
-    
+
     /**
      * Copies all properties from the given table to the new project - 
omitting those that have already been set in the
      * new project as well as properties named basedir or ant.file.
-     * 
+     *
      * @param props properties <code>Hashtable</code> to copy to the new 
project.
      * @param project the project where the properties are added
      */
@@ -73,7 +73,7 @@ public class AntUtil
 
     /**
      * Copy references from one project to another.
-     * 
+     *
      * @param fromProject
      * @param toProject
      */
@@ -81,11 +81,11 @@ public class AntUtil
     {
         copyReferences( fromProject.getReferences(), toProject );
     }
-    
+
     /**
      * Copy references from a hashtable to a project.  Will not
      * overwrite existing references.
-     * 
+     *
      * @param refs
      * @param project
      */


Reply via email to