Return-Path: Delivered-To: apmail-avalon-cvs-archive@www.apache.org Received: (qmail 63309 invoked from network); 20 Jun 2004 17:38:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 20 Jun 2004 17:38:25 -0000 Received: (qmail 7930 invoked by uid 500); 20 Jun 2004 17:38:26 -0000 Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 7845 invoked by uid 500); 20 Jun 2004 17:38:25 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 7827 invoked by uid 99); 20 Jun 2004 17:38:24 -0000 Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Sun, 20 Jun 2004 10:38:24 -0700 Received: (qmail 63252 invoked by uid 65534); 20 Jun 2004 17:38:21 -0000 Date: 20 Jun 2004 17:38:21 -0000 Message-ID: <20040620173821.63250.qmail@minotaur.apache.org> From: mcconnell@apache.org To: cvs@avalon.apache.org Subject: svn commit: rev 21512 - avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: mcconnell Date: Sun Jun 20 10:38:20 2004 New Revision: 21512 Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java Log: Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java ============================================================================== --- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java (original) +++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java Sun Jun 20 10:38:20 2004 @@ -19,6 +19,7 @@ import java.io.File; import java.io.IOException; +import java.io.FileNotFoundException; import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; @@ -50,6 +51,13 @@ private static Home HOME; + private String m_path; + + public void setIndex( String path ) + { + m_path = path; + } + public void init() { if( !isInitialized() ) @@ -77,7 +85,8 @@ String system = project.getProperty( SYSTEM_KEY ); if(( null == system ) || "".equals( system )) { - return index.getParentFile(); + File systemHome = index.getParentFile(); + return systemHome; } else { @@ -120,35 +129,51 @@ private File getIndexFile() { - String path = getProject().getProperty( Home.KEY ); - if( null != path ) + if( null != m_path ) + { + File index = Context.getFile( project.getBaseDir(), m_path ); + return resolve( index ); + } + else { - File index = Context.getFile( project.getBaseDir(), path ); - if( index.exists() ) + + // + // try to resolve using ${project.home} + // + + String path = getProject().getProperty( Home.KEY ); + if( null != path ) { - if( index.isDirectory() ) - { - return new File( index, "index.xml" ); - } - else - { - return index; - } + File root = Context.getFile( project.getBaseDir(), path ); + return resolve( root ); } else { final String error = - "Property value 'project.home' references a non-existant file: " - + index; + "Property value 'project.home' is not defined."; throw new BuildException( error ); } } + } + + private File resolve( File index ) + { + if( index.exists() ) + { + if( index.isDirectory() ) + { + return resolve( new File( index, "index.xml" ) ); + } + else + { + return index; + } + } else { - final String error = - "Cannot continue due to unresolved 'project.home' property."; - throw new BuildException( error ); + FileNotFoundException e = + new FileNotFoundException( index.toString() ); + throw new BuildException( e ); } } - } --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org