ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder DefaultProjectBuilder.java
Date Thu, 23 May 2002 04:32:10 GMT
donaldp     02/05/22 21:32:10

  Modified:    container/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java
  Log:
  If source is already a URL then don't try to URLize it again
  
  Revision  Changes    Path
  1.58      +42 -6     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- DefaultProjectBuilder.java	23 May 2002 01:50:25 -0000	1.57
  +++ DefaultProjectBuilder.java	23 May 2002 04:32:10 -0000	1.58
  @@ -9,9 +9,9 @@
   
   import java.io.File;
   import java.io.IOException;
  +import java.net.MalformedURLException;
  +import java.net.URL;
   import java.util.ArrayList;
  -import java.util.HashMap;
  -import java.util.Map;
   import java.util.StringTokenizer;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  @@ -35,7 +35,7 @@
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.57 $ $Date: 2002/05/23 01:50:25 $
  + * @version $Revision: 1.58 $ $Date: 2002/05/23 04:32:10 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
  @@ -73,10 +73,45 @@
       public Project build( final String source )
           throws ProjectException
       {
  -        final File file = new File( source );
  +        final File file = toFile( source );
           return build( file );
       }
   
  +    /**
  +     * Convert the specified source into a file object.
  +     *
  +     * @param source the source to transform
  +     * @return the file object
  +     * @throws ProjectException if malformed source
  +     */
  +    private File toFile( final String source )
  +        throws ProjectException
  +    {
  +        if( !source.startsWith( "file:" ) )
  +        {
  +            return new File( source );
  +        }
  +        else
  +        {
  +            try
  +            {
  +                final URL url = new URL( source );
  +                return new File( url.getFile() );
  +            }
  +            catch( final MalformedURLException mue )
  +            {
  +                throw new ProjectException( mue.getMessage(), mue );
  +            }
  +        }
  +    }
  +
  +    /**
  +     * build project from file.
  +     *
  +     * @param file the file
  +     * @return the create Project object
  +     * @throws ProjectException if error building project
  +     */
       private Project build( final File file )
           throws ProjectException
       {
  @@ -372,7 +407,7 @@
   
           try
           {
  -            final String uri =  file.getCanonicalFile().toString();
  +            final String uri = file.getCanonicalFile().toString();
               final ProjectRef ref = new ProjectRef( name, uri );
               project.addProjectRef( ref );
           }
  @@ -385,7 +420,8 @@
       /**
        * Validates a project file name, and builds the canonical URL for it.
        */
  -    private String extractURL( final File file ) throws ProjectException
  +    private String extractURL( final File file )
  +        throws ProjectException
       {
           if( !file.isFile() )
           {
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message