jvanzyl     2002/07/03 14:50:05

  Modified:    src/java/org/apache/maven/dependency ProjectResolver.java
  Log:
  Adjusting the project resolver so that when a source file can't be
  parsed the process can continue.
  
  Revision  Changes    Path
  1.2       +42 -20    
jakarta-turbine-maven/src/java/org/apache/maven/dependency/ProjectResolver.java
  
  Index: ProjectResolver.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/dependency/ProjectResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProjectResolver.java      28 May 2002 21:27:05 -0000      1.1
  +++ ProjectResolver.java      3 Jul 2002 21:50:05 -0000       1.2
  @@ -58,6 +58,8 @@
   
   import java.io.File;
   import java.io.FileInputStream;
  +import java.io.FileOutputStream;
  +import java.io.PrintStream;
   import java.util.Iterator;
   import java.util.List;
   import java.util.LinkedList;
  @@ -138,6 +140,11 @@
           this.base = base;
       }
   
  +    public File getBase()
  +    {
  +        return base;
  +    }        
  +
       /**
        * Set the location of the package -> project map.
        *
  @@ -176,9 +183,6 @@
       public void resolveDependencies()
           throws Exception
       {
  -        // Collect all the JAR and class file that we can find
  -        // in the base or just process the JAR.
  -        
           if (base.isDirectory())
           {
               String[] files =
  @@ -187,7 +191,14 @@
               for (int i = 0; i < files.length; i++)
               {
                   String file = files[i];
  -                st.parse(new FileInputStream(file));
  +                
  +                try
  +                {
  +                    st.parse(new FileInputStream(file));
  +                }
  +                catch (Exception e)
  +                {
  +                }
               }
           }
   
  @@ -257,24 +268,35 @@
           }
       }
   
  -    /**
  -     * Used for testing only.
  -     * @param args command line args
  -     * @throws Exception when any error occurs
  -     */
  -    public static void main(String[] args)
  +    public void execute()
           throws Exception
       {
  -        ProjectResolver bdr = new ProjectResolver();
  -        bdr.setBase(new File(args[0]));
  -        bdr.setPackageExcludes(args[1]);
  -        bdr.setMapFile(new File(args[2]));
  -        bdr.resolveDependencies();
  -
  -        List projectReferences = bdr.getProjectReferences();
  -        for (Iterator i = projectReferences.iterator(); i.hasNext();)
  +        try
           {
  -            System.out.println(i.next());
  +            resolveDependencies();
  +
  +            List projectReferences = getProjectReferences();
  +            
  +            File f = new File(getBase(), "deps.xml");
  +            PrintStream ps = new PrintStream( new FileOutputStream( new 
File(getBase(),"deps.xml") ) );
  +            
  +            for (Iterator i = projectReferences.iterator(); i.hasNext();)
  +            {
  +                String projectReference = (String) i.next();            
  +            
  +                ps.println("<dependency>");
  +                ps.println("<id>" + projectReference + "</id>");
  +                ps.println("<version>???</version>");
  +                ps.println("</dependency>");
  +            }
  +            ps.flush();
  +            ps.close();
  +            
           }
  +        catch (Exception e)
  +        {
  +            System.out.println(e);
  +        }            
  +        
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to