You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/06/20 19:38:21 UTC
svn commit: rev 21512 - avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks
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