You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ni...@apache.org on 2004/05/27 14:47:33 UTC
svn commit: rev 20501 - in avalon/trunk/tools/magic: . engine/src/java/org/apache/avalon/magic xdoc/src/dist
Author: niclas
Date: Thu May 27 05:47:32 2004
New Revision: 20501
Added:
avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/BuildException.java
Modified:
avalon/trunk/tools/magic/build.sequence
avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/CreationException.java
avalon/trunk/tools/magic/xdoc/src/dist/build.bsh
avalon/trunk/tools/magic/xdoc/src/dist/build.properties
Log:
Better error handling.
Modified: avalon/trunk/tools/magic/build.sequence
==============================================================================
--- avalon/trunk/tools/magic/build.sequence (original)
+++ avalon/trunk/tools/magic/build.sequence Thu May 27 05:47:32 2004
@@ -1,7 +1,7 @@
-prepare plugin.install
-xdoc plugin.install
-clean plugin.install
-artifact plugin.install
-java plugin.install
-jar plugin.install
+prepare plugin.install
+xdoc plugin.install
+clean plugin.install
+artifact plugin.install
+java plugin.install
+jar plugin.install
Added: avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/BuildException.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/BuildException.java Thu May 27 05:47:32 2004
@@ -0,0 +1,36 @@
+/*
+Copyright 2004 The Apache Software Foundation
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package org.apache.avalon.magic;
+
+
+public class BuildException extends Exception
+{
+ public BuildException()
+ {
+ }
+
+ public BuildException( String message )
+ {
+ super( message );
+ }
+
+ public BuildException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/CreationException.java
==============================================================================
--- avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/CreationException.java (original)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/avalon/magic/CreationException.java Thu May 27 05:47:32 2004
@@ -18,7 +18,7 @@
package org.apache.avalon.magic;
-public class CreationException extends Exception
+public class CreationException extends BuildException
{
public CreationException()
{
Modified: avalon/trunk/tools/magic/xdoc/src/dist/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/xdoc/src/dist/build.bsh (original)
+++ avalon/trunk/tools/magic/xdoc/src/dist/build.bsh Thu May 27 05:47:32 2004
@@ -36,9 +36,10 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.magic.AbstractPlugin;
-import org.apache.avalon.magic.RegexpFilter;
+import org.apache.avalon.magic.BuildException;
import org.apache.avalon.magic.Plugin;
import org.apache.avalon.magic.PluginContext;
+import org.apache.avalon.magic.RegexpFilter;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
@@ -59,7 +60,7 @@
}
public void generate()
- throws TransformerException
+ throws BuildException
{
getLogger().info( "Start XDoc generation." );
@@ -81,8 +82,8 @@
try
{
- transformNavigation( themeDir );
copySources();
+ transformNavigation( themeDir );
transformXdocs( themeDir );
copyResources( themeDir );
}
@@ -94,7 +95,7 @@
}
private void transformNavigation( File themeDir )
- throws TransformerException
+ throws BuildException
{
File xslFile = new File( themeDir, "nav-aggregate.xsl" );
String srcDir = m_Context.getProperty( "xdoc.src.dir" );
@@ -113,7 +114,7 @@
}
private void transformXdocs( File themeDir )
- throws TransformerException
+ throws BuildException
{
File xslFile = new File( themeDir, "transform.xsl" );
String srcDir = m_Context.getProperty( "xdoc.build.src.dir" );
@@ -148,7 +149,7 @@
private void transformTrax( File srcDir, File toDir, File xslFile,
String includes, String excludes, String extension,
String method )
- throws TransformerException
+ throws BuildException
{
/* Alternate 'direct' implementation to solve that I can feed
the XSL stylesheet with the parameter of the currently
@@ -160,20 +161,26 @@
System.out.println( "Transforming xsl:" + xslFile );
System.out.println( "Transforming includes/excludes: '" + includes + "' / '" + excludes + "'." );
- TransformerFactory factory = TransformerFactory.newInstance();
- StreamSource xsl = new StreamSource( xslFile );
- Transformer transformer = factory.newTransformer( xsl );
+ try
+ {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ StreamSource xsl = new StreamSource( xslFile );
+ Transformer transformer = factory.newTransformer( xsl );
- RegexpFilter filter = new RegexpFilter( includes, excludes );
-
- m_BaseDir = toDir;
-
- transform( transformer, srcDir, toDir, filter, extension );
+ RegexpFilter filter = new RegexpFilter( includes, excludes );
+
+ m_BaseDir = toDir;
+
+ transform( transformer, srcDir, toDir, filter, extension );
+ } catch( TransformerException e )
+ {
+ throw new BuildException( "Invalid XML/XSL configuration of your system.", e );
+ }
}
private void transform( Transformer transformer, File srcDir, File toDir,
FileFilter filter, String extension )
- throws TransformerException
+ throws BuildException
{
File[] content = srcDir.listFiles( filter );
for( int i = 0 ; i < content.length ; i++ )
@@ -182,6 +189,7 @@
if( content[i].isDirectory() )
{
File newDest = new File( toDir, base );
+ newDest.mkdirs();
transform( transformer, content[i], newDest, filter, extension );
}
if( content[i].isFile() )
@@ -202,7 +210,15 @@
transformer.setParameter( "fullpath", getRelPath( newDest ) );
transformer.setParameter( "file", base );
- transformer.transform( xml, out );
+ try
+ {
+ transformer.transform( xml, out );
+ } catch( Exception e )
+ {
+ getLogger().error( getRelPath( newDest ) + " : " + e.getMessage() );
+ if( "true".equals( m_Context.getProperty( "xdoc.fail.on.error" ) ) )
+ throw new BuildException( "Unable to transform document. Message above should give more details." );
+ }
}
}
}
Modified: avalon/trunk/tools/magic/xdoc/src/dist/build.properties
==============================================================================
--- avalon/trunk/tools/magic/xdoc/src/dist/build.properties (original)
+++ avalon/trunk/tools/magic/xdoc/src/dist/build.properties Thu May 27 05:47:32 2004
@@ -11,3 +11,4 @@
xdoc.output.format=html
+xdoc.fail.on.error = true
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org