donaldp 01/12/15 16:36:07
Modified:
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp
JspC.java WLJspc.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers
CompilerAdapter.java CompilerAdapterFactory.java
DefaultCompilerAdapter.java JasperC.java
Log:
BuildException -> TaskException
Removed uneeded imports.
Processed code through style formatter.
Revision Changes Path
1.3 +24 -23
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
Index: JspC.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JspC.java 2001/12/15 14:55:58 1.2
+++ JspC.java 2001/12/16 00:36:07 1.3
@@ -6,10 +6,11 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.jsp;
+
import java.io.File;
import java.util.Date;
import java.util.Vector;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.MatchingTask;
@@ -57,13 +58,13 @@
* </a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
* @author <a href="mailto:[EMAIL PROTECTED]">J D Glanville</a>
- * @version $Revision: 1.2 $ $Date: 2001/12/15 14:55:58 $
+ * @version $Revision: 1.3 $ $Date: 2001/12/16 00:36:07 $
*/
public class JspC extends MatchingTask
{
private final static String FAIL_MSG
- = "Compile failed, messages should have been provided.";
+ = "Compile failed, messages should have been provided.";
private int verbose = 0;
protected Vector compileList = new Vector();
protected boolean failOnError = true;
@@ -135,7 +136,7 @@
* ------------------------------------------------------------
*/
/**
- * Throw a BuildException if compilation fails
+ * Throw a TaskException if compilation fails
*
* @param fail The new Failonerror value
*/
@@ -318,24 +319,24 @@
* ------------------------------------------------------------
*/
public void execute()
- throws BuildException
+ throws TaskException
{
// first off, make sure that we've got a srcdir
if( src == null )
{
- throw new BuildException( "srcdir attribute must be set!" );
+ throw new TaskException( "srcdir attribute must be set!" );
}
String[] list = src.list();
if( list.length == 0 )
{
- throw new BuildException( "srcdir attribute must be set!" );
+ throw new TaskException( "srcdir attribute must be set!" );
}
if( destDir != null && !destDir.isDirectory() )
{
throw new
- BuildException( "destination directory \"" + destDir +
- "\" does not exist or is not a directory" );
+ TaskException( "destination directory \"" + destDir +
+ "\" does not exist or is not a directory" );
}
// calculate where the files will end up:
@@ -355,11 +356,11 @@
int filecount = 0;
for( int i = 0; i < list.length; i++ )
{
- File srcDir = ( File )resolveFile( list[i] );
+ File srcDir = (File)resolveFile( list[ i ] );
if( !srcDir.exists() )
{
- throw new BuildException( "srcdir \"" + srcDir.getPath() +
- "\" does not exist!" );
+ throw new TaskException( "srcdir \"" + srcDir.getPath() +
+ "\" does not exist!" );
}
DirectoryScanner ds = this.getDirectoryScanner( srcDir );
@@ -384,7 +385,7 @@
CompilerAdapter adapter =
CompilerAdapterFactory.getCompiler( compiler, this );
log( "Compiling " + compileList.size() +
- " source file"
+ " source file"
+ ( compileList.size() == 1 ? "" : "s" )
+ ( destDir != null ? " to " + destDir : "" ) );
@@ -396,7 +397,7 @@
{
if( failOnError )
{
- throw new BuildException( FAIL_MSG );
+ throw new TaskException( FAIL_MSG );
}
else
{
@@ -446,19 +447,19 @@
for( int i = 0; i < files.length; i++ )
{
- File srcFile = new File( srcDir, files[i] );
- if( files[i].endsWith( ".jsp" ) )
+ File srcFile = new File( srcDir, files[ i ] );
+ if( files[ i ].endsWith( ".jsp" ) )
{
// drop leading path (if any)
int fileStart =
- files[i].lastIndexOf( File.separatorChar ) + 1;
- File javaFile = new File( destDir, files[i].substring(
fileStart,
- files[i].indexOf( ".jsp" ) ) + ".java" );
+ files[ i ].lastIndexOf( File.separatorChar ) + 1;
+ File javaFile = new File( destDir, files[ i ].substring(
fileStart,
+
files[ i ].indexOf( ".jsp" ) ) + ".java" );
if( srcFile.lastModified() > now )
{
log( "Warning: file modified in the future: " +
- files[i], Project.MSG_WARN );
+ files[ i ], Project.MSG_WARN );
}
if( !javaFile.exists() ||
@@ -467,14 +468,14 @@
if( !javaFile.exists() )
{
log( "Compiling " + srcFile.getPath() +
- " because java file "
+ " because java file "
+ javaFile.getPath() + " does not exist",
- Project.MSG_DEBUG );
+ Project.MSG_DEBUG );
}
else
{
log( "Compiling " + srcFile.getPath() +
- " because it is out of date with respect to "
+ " because it is out of date with respect to "
+ javaFile.getPath(), Project.MSG_DEBUG );
}
compileList.addElement( srcFile.getAbsolutePath() );
1.3 +35 -37
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
Index: WLJspc.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WLJspc.java 2001/12/15 14:55:58 1.2
+++ WLJspc.java 2001/12/16 00:36:07 1.3
@@ -6,14 +6,15 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.jsp;//java imports
+
import java.io.File;
import java.util.Date;
import java.util.StringTokenizer;
import java.util.Vector;
-import org.apache.tools.ant.BuildException;
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Java;//apache/ant imports
+import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.Path;
@@ -67,7 +68,6 @@
private String destinationPackage;//root of compiled files tree
private File sourceDirectory;
-
/**
* Set the classpath to be used for this compilation.
*
@@ -133,23 +133,23 @@
}
public void execute()
- throws BuildException
+ throws TaskException
{
if( !destinationDirectory.isDirectory() )
{
- throw new BuildException( "destination directory " +
destinationDirectory.getPath() +
- " is not valid" );
+ throw new TaskException( "destination directory " +
destinationDirectory.getPath() +
+ " is not valid" );
}
if( !sourceDirectory.isDirectory() )
{
- throw new BuildException( "src directory " +
sourceDirectory.getPath() +
- " is not valid" );
+ throw new TaskException( "src directory " +
sourceDirectory.getPath() +
+ " is not valid" );
}
if( destinationPackage == null )
{
- throw new BuildException( "package attribute must be present." );
+ throw new TaskException( "package attribute must be present." );
}
String systemClassPath = System.getProperty( "java.class.path" );
@@ -171,31 +171,31 @@
// Therefore, takes loads of time
// Can pass directories at a time (*.jsp) but easily runs out of
memory on hefty dirs
// (even on a Sun)
- Java helperTask = ( Java )project.createTask( "java" );
+ Java helperTask = (Java)project.createTask( "java" );
helperTask.setFork( true );
helperTask.setClassname( "weblogic.jspc" );
helperTask.setTaskName( getTaskName() );
- String[] args = new String[12];
+ String[] args = new String[ 12 ];
File jspFile = null;
String parents = "";
String arg = "";
int j = 0;
//XXX this array stuff is a remnant of prev trials.. gotta remove.
- args[j++] = "-d";
- args[j++] = destinationDirectory.getAbsolutePath().trim();
- args[j++] = "-docroot";
- args[j++] = sourceDirectory.getAbsolutePath().trim();
- args[j++] = "-keepgenerated";//TODO: Parameterise ??
+ args[ j++ ] = "-d";
+ args[ j++ ] = destinationDirectory.getAbsolutePath().trim();
+ args[ j++ ] = "-docroot";
+ args[ j++ ] = sourceDirectory.getAbsolutePath().trim();
+ args[ j++ ] = "-keepgenerated";//TODO: Parameterise ??
//Call compiler as class... dont want to fork again
//Use classic compiler -- can be parameterised?
- args[j++] = "-compilerclass";
- args[j++] = "sun.tools.javac.Main";
+ args[ j++ ] = "-compilerclass";
+ args[ j++ ] = "sun.tools.javac.Main";
//Weblogic jspc does not seem to work unless u explicitly set this...
// Does not take the classpath from the env....
// Am i missing something about the Java task??
- args[j++] = "-classpath";
- args[j++] = compileClasspath.toString();
+ args[ j++ ] = "-classpath";
+ args[ j++ ] = compileClasspath.toString();
this.scanDir( files );
log( "Compiling " + filesToDo.size() + " JSP files" );
@@ -206,25 +206,25 @@
// All this to get package according to weblogic standards
// Can be written better... this is too hacky!
// Careful.. similar code in scanDir , but slightly different!!
- jspFile = new File( ( String )filesToDo.elementAt( i ) );
- args[j] = "-package";
+ jspFile = new File( (String)filesToDo.elementAt( i ) );
+ args[ j ] = "-package";
parents = jspFile.getParent();
if( ( parents != null ) && ( !( "" ).equals( parents ) ) )
{
parents = this.replaceString( parents, File.separator, "_."
);
- args[j + 1] = destinationPackage + "." + "_" + parents;
+ args[ j + 1 ] = destinationPackage + "." + "_" + parents;
}
else
{
- args[j + 1] = destinationPackage;
+ args[ j + 1 ] = destinationPackage;
}
- args[j + 2] = sourceDirectory + File.separator + ( String
)filesToDo.elementAt( i );
+ args[ j + 2 ] = sourceDirectory + File.separator +
(String)filesToDo.elementAt( i );
arg = "";
for( int x = 0; x < 12; x++ )
{
- arg += " " + args[x];
+ arg += " " + args[ x ];
}
System.out.println( "arg = " + arg );
@@ -234,12 +234,11 @@
helperTask.setClasspath( compileClasspath );
if( helperTask.executeJava() != 0 )
{
- log( files[i] + " failed to compile", Project.MSG_WARN );
+ log( files[ i ] + " failed to compile", Project.MSG_WARN );
}
}
}
-
protected String replaceString( String inpString, String escapeChars,
String replaceChars )
{
String localString = "";
@@ -255,7 +254,6 @@
return localString;
}
-
protected void scanDir( String files[] )
{
@@ -265,11 +263,11 @@
String pack = "";
for( int i = 0; i < files.length; i++ )
{
- File srcFile = new File( this.sourceDirectory, files[i] );
+ File srcFile = new File( this.sourceDirectory, files[ i ] );
//XXX
// All this to convert source to destination directory according
to weblogic standards
// Can be written better... this is too hacky!
- jspFile = new File( files[i] );
+ jspFile = new File( files[ i ] );
parents = jspFile.getParent();
int loc = 0;
@@ -285,27 +283,27 @@
String filePath = pack + File.separator + "_";
int startingIndex
- = files[i].lastIndexOf( File.separator ) != -1 ?
files[i].lastIndexOf( File.separator ) + 1 : 0;
- int endingIndex = files[i].indexOf( ".jsp" );
+ = files[ i ].lastIndexOf( File.separator ) != -1 ? files[ i
].lastIndexOf( File.separator ) + 1 : 0;
+ int endingIndex = files[ i ].indexOf( ".jsp" );
if( endingIndex == -1 )
{
break;
}
- filePath += files[i].substring( startingIndex, endingIndex );
+ filePath += files[ i ].substring( startingIndex, endingIndex );
filePath += ".class";
File classFile = new File( this.destinationDirectory, filePath );
if( srcFile.lastModified() > now )
{
log( "Warning: file modified in the future: " +
- files[i], Project.MSG_WARN );
+ files[ i ], Project.MSG_WARN );
}
if( srcFile.lastModified() > classFile.lastModified() )
{
//log("Files are" + srcFile.getAbsolutePath()+" "
+classFile.getAbsolutePath());
- filesToDo.addElement( files[i] );
- log( "Recompiling File " + files[i], Project.MSG_VERBOSE );
+ filesToDo.addElement( files[ i ] );
+ log( "Recompiling File " + files[ i ], Project.MSG_VERBOSE );
}
}
}
1.2 +4 -3
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/CompilerAdapter.java
Index: CompilerAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/CompilerAdapter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CompilerAdapter.java 2001/12/15 12:06:28 1.1
+++ CompilerAdapter.java 2001/12/16 00:36:07 1.2
@@ -6,7 +6,8 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
-import org.apache.tools.ant.BuildException;
+
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
/**
@@ -37,8 +38,8 @@
* Executes the task.
*
* @return has the compilation been successful
- * @exception BuildException Description of Exception
+ * @exception TaskException Description of Exception
*/
boolean execute()
- throws BuildException;
+ throws TaskException;
}
1.2 +15 -13
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/CompilerAdapterFactory.java
Index: CompilerAdapterFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/CompilerAdapterFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CompilerAdapterFactory.java 2001/12/15 12:06:28 1.1
+++ CompilerAdapterFactory.java 2001/12/16 00:36:07 1.2
@@ -6,9 +6,9 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.tools.ant.Task;
/**
* Creates the necessary compiler adapter, given basic criteria.
@@ -22,7 +22,9 @@
/**
* This is a singlton -- can't create instances!!
*/
- private CompilerAdapterFactory() { }
+ private CompilerAdapterFactory()
+ {
+ }
/**
* Based on the parameter passed in, this method creates the necessary
@@ -39,11 +41,11 @@
* classname of the compiler's adapter.
* @param task a task to log through.
* @return The Compiler value
- * @throws BuildException if the compiler type could not be resolved
into a
+ * @throws TaskException if the compiler type could not be resolved into
a
* compiler adapter.
*/
public static CompilerAdapter getCompiler( String compilerType, Task
task )
- throws BuildException
+ throws TaskException
{
/*
* If I've done things right, this should be the extent of the
@@ -62,32 +64,32 @@
*
* @param className The fully qualified classname to be created.
* @return Description of the Returned Value
- * @throws BuildException This is the fit that is thrown if className
isn't
+ * @throws TaskException This is the fit that is thrown if className
isn't
* an instance of CompilerAdapter.
*/
private static CompilerAdapter resolveClassName( String className )
- throws BuildException
+ throws TaskException
{
try
{
Class c = Class.forName( className );
Object o = c.newInstance();
- return ( CompilerAdapter )o;
+ return (CompilerAdapter)o;
}
catch( ClassNotFoundException cnfe )
{
- throw new BuildException( className + " can\'t be found.", cnfe
);
+ throw new TaskException( className + " can\'t be found.", cnfe );
}
catch( ClassCastException cce )
{
- throw new BuildException( className + " isn\'t the classname of "
- + "a compiler adapter.", cce );
+ throw new TaskException( className + " isn\'t the classname of "
+ + "a compiler adapter.", cce );
}
catch( Throwable t )
{
// for all other possibilities
- throw new BuildException( className + " caused an interesting "
- + "exception.", t );
+ throw new TaskException( className + " caused an interesting "
+ + "exception.", t );
}
}
1.2 +3 -2
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultCompilerAdapter.java
Index: DefaultCompilerAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultCompilerAdapter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultCompilerAdapter.java 2001/12/15 12:06:28 1.1
+++ DefaultCompilerAdapter.java 2001/12/16 00:36:07 1.2
@@ -6,6 +6,7 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
+
import java.util.Enumeration;
import java.util.Vector;
import org.apache.tools.ant.Project;
@@ -19,7 +20,7 @@
* @author Matthew Watson <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
*/
public abstract class DefaultCompilerAdapter
- implements CompilerAdapter
+ implements CompilerAdapter
{
/*
* ------------------------------------------------------------
@@ -69,7 +70,7 @@
Enumeration enum = compileList.elements();
while( enum.hasMoreElements() )
{
- String arg = ( String )enum.nextElement();
+ String arg = (String)enum.nextElement();
cmd.createArgument().setValue( arg );
niceSourceList.append( " " + arg + lSep );
}
1.3 +9 -8
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
Index: JasperC.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JasperC.java 2001/12/15 14:55:58 1.2
+++ JasperC.java 2001/12/16 00:36:07 1.3
@@ -6,7 +6,8 @@
* the LICENSE file.
*/
package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
-import org.apache.tools.ant.BuildException;
+
+import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
@@ -24,7 +25,7 @@
* ------------------------------------------------------------
*/
public boolean execute()
- throws BuildException
+ throws TaskException
{
getJspc().log( "Using jasper compiler", Project.MSG_VERBOSE );
Commandline cmd = setupJasperCommand();
@@ -33,27 +34,27 @@
{
// Create an instance of the compiler, redirecting output to
// the project log
- Java java = ( Java )( getJspc().getProject() ).createTask(
"java" );
+ Java java = (Java)( getJspc().getProject() ).createTask( "java"
);
if( getJspc().getClasspath() != null )
java.setClasspath( getJspc().getClasspath() );
java.setClassname( "org.apache.jasper.JspC" );
String args[] = cmd.getArguments();
for( int i = 0; i < args.length; i++ )
- java.createArg().setValue( args[i] );
+ java.createArg().setValue( args[ i ] );
java.setFailonerror( true );
java.execute();
return true;
}
catch( Exception ex )
{
- if( ex instanceof BuildException )
+ if( ex instanceof TaskException )
{
- throw ( BuildException )ex;
+ throw (TaskException)ex;
}
else
{
- throw new BuildException( "Error running jsp compiler: ",
- ex );
+ throw new TaskException( "Error running jsp compiler: ",
+ ex );
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>