adammurdoch 02/05/27 20:52:21
Modified: framework/src/java/org/apache/myrmidon/framework
ExecuteTarget.java Resources.properties
Log:
Better error reporting for the <ant> tasks.
Revision Changes Path
1.7 +39 -17
jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/ExecuteTarget.java
Index: ExecuteTarget.java
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/ExecuteTarget.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ExecuteTarget.java 23 May 2002 04:31:15 -0000 1.6
+++ ExecuteTarget.java 28 May 2002 03:52:21 -0000 1.7
@@ -16,6 +16,8 @@
import org.apache.myrmidon.interfaces.oldmodel.Project;
import org.apache.myrmidon.interfaces.workspace.Workspace;
import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
/**
* A utility class that simplifies executing a target in a project.
@@ -23,10 +25,13 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Darrell DeBoer</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
- * @version $Revision: 1.6 $ $Date: 2002/05/23 04:31:15 $
+ * @version $Revision: 1.7 $ $Date: 2002/05/28 03:52:21 $
*/
public class ExecuteTarget
{
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( ExecuteTarget.class );
+
private boolean m_inheritAll;
private String m_target;
private Project m_project;
@@ -87,33 +92,50 @@
public void execute( final TaskContext context )
throws TaskException
{
- try
- {
- final Embeddor embeddor = (Embeddor)context.getService(
Embeddor.class );
+ final Embeddor embeddor = (Embeddor)context.getService(
Embeddor.class );
+ final Project project = buildProject( embeddor );
+ final Map properties = buildParameters( context );
- Project project = m_project;
- if( project == null )
- {
- project = embeddor.createProject(
m_projectFile.getAbsolutePath(), m_projectType, null );
- }
+ String target = m_target;
+ if( null == target )
+ {
+ target = project.getDefaultTargetName();
+ }
+ try
+ {
// TODO - need to be able to inherit services (TypeManager
specifically)
final Workspace workspace = embeddor.createWorkspace();
final ExecutionFrame frame =
- embeddor.createExecutionFrame( buildParameters( context ) );
-
- String target = m_target;
- if( null == target )
- {
- target = project.getDefaultTargetName();
- }
+ embeddor.createExecutionFrame( properties );
workspace.setFrame( frame );
workspace.executeProject( project, target );
}
catch( final Exception e )
{
- throw new TaskException( e.toString(), e );
+ final String message = REZ.getString(
"execute-target.execute.error", project.getName(), target );
+ throw new TaskException( message, e );
+ }
+ }
+
+ /**
+ * Returns the project to execute.
+ */
+ private Project buildProject( final Embeddor embeddor ) throws
TaskException
+ {
+ try
+ {
+ if( m_project != null )
+ {
+ return m_project;
+ }
+ return embeddor.createProject( m_projectFile.getAbsolutePath(),
m_projectType, null );
+ }
+ catch( final Exception e )
+ {
+ final String message = REZ.getString(
"execute-target.create-project.error" );
+ throw new TaskException( message, e );
}
}
1.4 +3 -0
jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/Resources.properties
Index: Resources.properties
===================================================================
RCS file:
/home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/Resources.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Resources.properties 22 May 2002 07:36:24 -0000 1.3
+++ Resources.properties 28 May 2002 03:52:21 -0000 1.4
@@ -19,3 +19,6 @@
unknown-family=Don't know how to detect os family "{0}"
facade.missing-impl.error=Unable to determine the name of implementation for
facade task "{0}".
+
+execute-target.execute.error=Execution of target "{1}" in project "{0}"
failed.
+execute-target.create-project.error=Could not create project to execute.
\ No newline at end of file
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>