Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 47519 invoked from network); 23 May 2002 04:32:18 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 23 May 2002 04:32:18 -0000 Received: (qmail 15677 invoked by uid 97); 23 May 2002 04:32:25 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 15610 invoked by uid 97); 23 May 2002 04:32:24 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 15599 invoked by uid 97); 23 May 2002 04:32:23 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 23 May 2002 04:32:10 -0000 Message-ID: <20020523043210.80044.qmail@icarus.apache.org> From: donaldp@apache.org To: jakarta-ant-myrmidon-cvs@apache.org Subject: cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder DefaultProjectBuilder.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 Peter Donald - * @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: For additional commands, e-mail: