dion        2002/06/24 20:07:11

  Modified:    src/java/org/apache/maven/build ProjectDescriptor.java
                        PluginDescriptor.java
               src/java/org/apache/maven/app Maven.java
  Log:
  Change to use DescriptorException
  
  Revision  Changes    Path
  1.5       +44 -30    
jakarta-turbine-maven/src/java/org/apache/maven/build/ProjectDescriptor.java
  
  Index: ProjectDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/build/ProjectDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProjectDescriptor.java    24 Jun 2002 02:43:05 -0000      1.4
  +++ ProjectDescriptor.java    25 Jun 2002 03:07:10 -0000      1.5
  @@ -95,40 +95,60 @@
        * Create a ProjectDescriptor object given a file descriptor.
        *
        * @param file a maven project.xml {@link File}
  -     * @throws IntrospectionException if there are issues reading a 
  +     * @throws DescriptorException if there are issues reading a 
        *      {@link Project} object 
  -     * @throws FileNotFoundException when a file used is not available during 
  -     *      formatting or transformation
  -     * @throws IOException when errors occur reading or writing
  -     * @throws SAXException when problems occur parsing XML
  -     */
  -    public ProjectDescriptor(File file) throws IntrospectionException, 
  -        FileNotFoundException, IOException, SAXException
  -    {
  -        BeanReader reader = new BeanReader(Project.class);
  -        project = (Project) reader.parse(
  -            new FileInputStream(file));
  -        this.file = file;
  +     */
  +    public ProjectDescriptor(File file) throws DescriptorException
  +    {
  +        parseProject(file);
       }
   
       /**
        * Create a ProjectDescriptor object given a descriptor file name
        *
        * @param fileName a maven project.xml {@link File} name
  -     * @throws IntrospectionException if there are issues reading a 
  +     * @throws DescriptorException if there are issues reading a 
        *      {@link Project} object 
  -     * @throws FileNotFoundException when a file used is not available during 
  -     *      formatting or transformation
  -     * @throws IOException when errors occur reading or writing
  -     * @throws SAXException when problems occur parsing XML
        */
  -    public ProjectDescriptor(String fileName) throws IntrospectionException, 
  -        FileNotFoundException, IOException, SAXException
  +    public ProjectDescriptor(String fileName) throws DescriptorException
       {
           this(new File(fileName));
       }
   
       /**
  +     * Read the project from the descriptor
  +     *
  +     * @param file a maven project.xml {@link File}
  +     * @throws DescriptorException if there are issues reading a 
  +     *      {@link Project} object 
  +     */
  +    private void parseProject(File file) throws DescriptorException
  +    {
  +        try
  +        {
  +            BeanReader reader = new BeanReader(Project.class);
  +            project = (Project) reader.parse(new FileInputStream(file));
  +            this.file = file;
  +        }
  +        catch (IntrospectionException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
  +        catch (FileNotFoundException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
  +        catch (IOException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
  +        catch (SAXException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
  +    }
  +    
  +    /**
        * Getter for property file.
        *
        * @return Value of property file.
  @@ -173,22 +193,16 @@
        * by {@link MavenConstants#POM_VERSION}, if it was read in from a file
        *
        * @param mavenHome is the base directory used to find maven utilities
  -     * @throws IntrospectionException if there are issues reading a 
  +     * @throws DescriptorException if there are issues reading a 
        *      {@link Project} object 
  -     * @throws FileNotFoundException when a file used is not available during 
  -     *      formatting or transformation
  -     * @throws IOException when errors occur reading or writing
  -     * @throws SAXException when problems occur parsing XML
        * @throws Exception when someother component fails
        */
  -    public void upgrade(String mavenHome) throws IntrospectionException, 
  -        FileNotFoundException, IOException, SAXException, Exception
  +    public void upgrade(String mavenHome) throws DescriptorException, Exception
       {
           translate(mavenHome);
           reformat();
           // reload POM
  -        BeanReader reader = new BeanReader(Project.class);
  -        project = (Project) reader.parse(new FileInputStream(getFile()));
  +        parseProject(getFile());
       }
       
       /**
  
  
  
  1.2       +26 -12    
jakarta-turbine-maven/src/java/org/apache/maven/build/PluginDescriptor.java
  
  Index: PluginDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/build/PluginDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PluginDescriptor.java     24 Jun 2002 03:15:46 -0000      1.1
  +++ PluginDescriptor.java     25 Jun 2002 03:07:10 -0000      1.2
  @@ -85,19 +85,33 @@
        * Create a PluginDescriptor object given a file descriptor.
        *
        * @param file a maven plugin.xml {@link File}
  -     * @throws IntrospectionException if there are issues reading a 
  -     *      {@link Plugin} object 
  -     * @throws FileNotFoundException when a file used is not available during 
  -     *      formatting or transformation
  -     * @throws IOException when errors occur reading or writing
  -     * @throws SAXException when problems occur parsing XML
  +     * @throws DescriptorException if there are issues reading a {@link Plugin}
  +     *      object 
        */
  -    public PluginDescriptor(File file) throws IntrospectionException, 
  -        FileNotFoundException, IOException, SAXException
  +    public PluginDescriptor(File file) throws DescriptorException
       {
  -        BeanReader reader = new BeanReader(Plugin.class);
  -        plugin = (Plugin) reader.parse(new FileInputStream(file));
  -        this.file = file;
  +        try
  +        {
  +            BeanReader reader = new BeanReader(Plugin.class);
  +            plugin = (Plugin) reader.parse(new FileInputStream(file));
  +            this.file = file;
  +        }
  +        catch (IntrospectionException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
  +        catch (FileNotFoundException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
  +        catch (IOException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
  +        catch (SAXException e)
  +        {
  +            throw new DescriptorException(e);
  +        }
       }
       
       //--------------------------------------------------------------------------
  
  
  
  1.13      +5 -18     jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java
  
  Index: Maven.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/app/Maven.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Maven.java        24 Jun 2002 23:40:46 -0000      1.12
  +++ Maven.java        25 Jun 2002 03:07:11 -0000      1.13
  @@ -56,6 +56,7 @@
    * ====================================================================
    */
   
  +import org.apache.maven.build.DescriptorException;
   import org.apache.maven.build.ProjectDescriptor;
   import org.apache.maven.build.RepositoryManager;
   import org.apache.maven.plugin.PluginManager;
  @@ -507,7 +508,7 @@
        *          reading the project descriptor.
        */
       public void initializeCore(String[] args)
  -        throws ParseException, IntrospectionException, IOException, 
MalformedURLException, SAXException
  +        throws ParseException, MalformedURLException, DescriptorException
       {
   
           setMavenHome(new File(System.getProperty("maven.home")));
  @@ -530,15 +531,11 @@
   
       /** Load the maven project descriptor.
        *
  -     *  @throws IntrospectionException If there is an error while
  -     *          reading the project descriptor.
  -     *  @throws IOException If there is an error while
  -     *          reading the project descriptor.
  -     *  @throws SAXException If there is an error while
  +     *  @throws DescriptorException If there is an error while
        *          reading the project descriptor.
        */
       void initializeProjectDescriptor()
  -        throws IntrospectionException, IOException, SAXException
  +        throws DescriptorException
       {
           this.projectDescriptor = new ProjectDescriptor(getProjectFile());
       }
  @@ -1186,17 +1183,7 @@
               System.err.println(e.getLocalizedMessage());
               done = true;
           }
  -        catch (IOException e)
  -        {
  -            System.err.println(e.getLocalizedMessage());
  -            done = true;
  -        }
  -        catch (SAXException e)
  -        {
  -            System.err.println(e.getLocalizedMessage());
  -            done = true;
  -        }
  -        catch (IntrospectionException e)
  +        catch (DescriptorException e)
           {
               System.err.println(e.getLocalizedMessage());
               done = true;
  
  
  

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

Reply via email to