git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274848 13f79535-47bb-0310-9956-ffa450edef68master
@@ -257,7 +257,6 @@ public class DemuxOutputStream extends OutputStream { | |||
// either end of buffer or a line separator char | |||
int blockLength = offset - blockStartOffset; | |||
if (blockLength > 0) { | |||
project.log("Sending " + blockLength); | |||
bufferInfo.buffer.write(b, blockStartOffset, blockLength); | |||
} | |||
while(remaining > 0 && (b[offset] == 0x0a || b[offset] == 0x0d)) { | |||
@@ -735,8 +735,8 @@ public class Javac extends MatchingTask { | |||
File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); | |||
if (newFiles.length > 0) { | |||
File[] newCompileList = new File[compileList.length + | |||
newFiles.length]; | |||
File[] newCompileList | |||
= new File[compileList.length + newFiles.length]; | |||
System.arraycopy(compileList, 0, newCompileList, 0, | |||
compileList.length); | |||
System.arraycopy(newFiles, 0, newCompileList, | |||
@@ -751,12 +751,12 @@ public class Javac extends MatchingTask { | |||
} | |||
protected boolean isJdkCompiler(String compilerImpl) { | |||
return "modern".equals(compilerImpl) || | |||
"classic".equals(compilerImpl) || | |||
"javac1.1".equals(compilerImpl) || | |||
"javac1.2".equals(compilerImpl) || | |||
"javac1.3".equals(compilerImpl) || | |||
"javac1.4".equals(compilerImpl); | |||
return "modern".equals(compilerImpl) | |||
|| "classic".equals(compilerImpl) | |||
|| "javac1.1".equals(compilerImpl) | |||
|| "javac1.2".equals(compilerImpl) | |||
|| "javac1.3".equals(compilerImpl) | |||
|| "javac1.4".equals(compilerImpl); | |||
} | |||
protected String getSystemJavac() { | |||
@@ -854,13 +854,12 @@ public class Javac extends MatchingTask { | |||
String compilerImpl = getCompiler(); | |||
if (compileList.length > 0) { | |||
log("Compiling " + compileList.length + | |||
" source file" | |||
log("Compiling " + compileList.length + " source file" | |||
+ (compileList.length == 1 ? "" : "s") | |||
+ (destDir != null ? " to " + destDir : "")); | |||
if (listFiles) { | |||
for (int i = 0 ; i < compileList.length ; i++) { | |||
for (int i = 0; i < compileList.length; i++) { | |||
String filename = compileList[i].getAbsolutePath(); | |||
log(filename) ; | |||
} | |||
@@ -313,7 +313,17 @@ public class Javadoc extends Task { | |||
/** The source file */ | |||
private File file; | |||
public SourceFile() {} | |||
/** | |||
* Default constructor | |||
*/ | |||
public SourceFile() { | |||
} | |||
/** | |||
* Constructor specifying the source file directly | |||
* | |||
* @param file the source file | |||
*/ | |||
public SourceFile(File file) { | |||
this.file = file; | |||
} | |||
@@ -390,9 +400,9 @@ public class Javadoc extends Task { | |||
/** Flag which indicates if javadoc from JDK 1.4 is available */ | |||
private static boolean javadoc4 = | |||
(!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) && | |||
!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) && | |||
!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)); | |||
!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) | |||
&& !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) | |||
&& !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3); | |||
/** | |||
* Utility method to add an argument to the command line conditionally | |||
@@ -446,7 +456,7 @@ public class Javadoc extends Task { | |||
private Path sourcePath = null; | |||
private File destDir = null; | |||
private Vector sourceFiles = new Vector(); | |||
private Vector packageNames = new Vector(5); | |||
private Vector packageNames = new Vector(); | |||
private Vector excludePackageNames = new Vector(1); | |||
private boolean author = true; | |||
private boolean version = true; | |||
@@ -455,9 +465,9 @@ public class Javadoc extends Task { | |||
private Path bootclasspath = null; | |||
private String group = null; | |||
private String packageList = null; | |||
private Vector links = new Vector(2); | |||
private Vector groups = new Vector(2); | |||
private Vector tags = new Vector(5); | |||
private Vector links = new Vector(); | |||
private Vector groups = new Vector(); | |||
private Vector tags = new Vector(); | |||
private boolean useDefaultExcludes = true; | |||
private Html doctitle = null; | |||
private Html header = null; | |||
@@ -1063,6 +1073,8 @@ public class Javadoc extends Task { | |||
/** | |||
* Link to docs at "url" using package list at "url2" | |||
* - separate the URLs by using a space character. | |||
* | |||
* @param src the offline link specification (url and package list) | |||
*/ | |||
public void setLinkoffline(String src) { | |||
if (!javadoc1) { | |||
@@ -1086,6 +1098,10 @@ public class Javadoc extends Task { | |||
/** | |||
* Group specified packages together in overview page. | |||
* | |||
* @param src the group packages - a command separated list of group specs, | |||
* each one being a group name and package specification separated | |||
* by a space. | |||
*/ | |||
public void setGroup(String src) { | |||
group = src; | |||
@@ -1101,49 +1117,63 @@ public class Javadoc extends Task { | |||
} | |||
/** | |||
* If true, do not include @deprecated information. | |||
* Control deprecation infromation | |||
* | |||
* @param b If true, do not include deprecated information. | |||
*/ | |||
public void setNodeprecated(boolean b) { | |||
addArgIf(b, "-nodeprecated"); | |||
} | |||
/** | |||
* If true, do not generate deprecated list. | |||
* Control deprecated list generation | |||
* | |||
* @param b if true, do not generate deprecated list. | |||
*/ | |||
public void setNodeprecatedlist(boolean b) { | |||
add12ArgIf(b, "-nodeprecatedlist"); | |||
} | |||
/** | |||
* If true, do not generate class hierarchy. | |||
* Control class tree generation. | |||
* | |||
* @param b if true, do not generate class hierarchy. | |||
*/ | |||
public void setNotree(boolean b) { | |||
addArgIf(b, "-notree"); | |||
} | |||
/** | |||
* If true, do not generate index. | |||
* Control generation of index. | |||
* | |||
* @param b if true, do not generate index. | |||
*/ | |||
public void setNoindex(boolean b) { | |||
addArgIf(b, "-noindex"); | |||
} | |||
/** | |||
* If true, do not generate help link | |||
* Control generation of help link. | |||
* | |||
* @param b if true, do not generate help link | |||
*/ | |||
public void setNohelp(boolean b) { | |||
add12ArgIf(b, "-nohelp"); | |||
} | |||
/** | |||
* If true, do not generate navigation bar. | |||
* Control generation of the navigation bar. | |||
* | |||
* @param b if true, do not generate navigation bar. | |||
*/ | |||
public void setNonavbar(boolean b) { | |||
add12ArgIf(b, "-nonavbar"); | |||
} | |||
/** | |||
* If true, generate warning about @serial tag. | |||
* Control warnings about serial tag. | |||
* | |||
* @param b if true, generate warning aboutthe serial tag. | |||
*/ | |||
public void setSerialwarn(boolean b) { | |||
add12ArgIf(b, "-serialwarn"); | |||
@@ -1151,6 +1181,8 @@ public class Javadoc extends Task { | |||
/** | |||
* Specifies the CSS stylesheet file to use. | |||
* | |||
* @param f the file with the CSS to use. | |||
*/ | |||
public void setStylesheetfile(File f) { | |||
if (!javadoc1) { | |||
@@ -1161,6 +1193,8 @@ public class Javadoc extends Task { | |||
/** | |||
* Specifies the HTML help file to use. | |||
* | |||
* @param f the file containing help content. | |||
*/ | |||
public void setHelpfile(File f) { | |||
if (!javadoc1) { | |||
@@ -1171,6 +1205,8 @@ public class Javadoc extends Task { | |||
/** | |||
* Output file encoding name. | |||
* | |||
* @param enc name of the encoding to use. | |||
*/ | |||
public void setDocencoding(String enc) { | |||
cmd.createArgument().setValue("-docencoding"); | |||
@@ -1179,6 +1215,8 @@ public class Javadoc extends Task { | |||
/** | |||
* The name of a file containing the packages to process. | |||
* | |||
* @param src the file containing the package list. | |||
*/ | |||
public void setPackageList(String src) { | |||
if (!javadoc1) { | |||
@@ -1188,6 +1226,8 @@ public class Javadoc extends Task { | |||
/** | |||
* Create link to javadoc output at the given URL. | |||
* | |||
* @param link argument to configure | |||
*/ | |||
public LinkArgument createLink() { | |||
LinkArgument la = new LinkArgument(); | |||
@@ -1195,6 +1235,10 @@ public class Javadoc extends Task { | |||
return la; | |||
} | |||
/** | |||
* Represents a link triplet (href, whether link is offline, location of the | |||
* package list if off line) | |||
*/ | |||
public class LinkArgument { | |||
private String href; | |||
private boolean offline = false; | |||
@@ -1334,8 +1378,9 @@ public class Javadoc extends Task { | |||
} else { | |||
int i; | |||
for (i = 0; i < SCOPE_ELEMENTS.length; i++) { | |||
if (next.equals (SCOPE_ELEMENTS[i])) | |||
if (next.equals (SCOPE_ELEMENTS[i])) { | |||
break; | |||
} | |||
} | |||
if (i == SCOPE_ELEMENTS.length) { | |||
throw new BuildException ("Unrecognised scope element: " | |||
@@ -1412,7 +1457,7 @@ public class Javadoc extends Task { | |||
public class GroupArgument { | |||
private Html title; | |||
private Vector packages = new Vector(3); | |||
private Vector packages = new Vector(); | |||
public GroupArgument() { | |||
} | |||
@@ -1765,7 +1810,7 @@ public class Javadoc extends Task { | |||
while (tok.hasMoreTokens()) { | |||
String grp = tok.nextToken().trim(); | |||
int space = grp.indexOf(" "); | |||
if (space > 0){ | |||
if (space > 0) { | |||
String name = grp.substring(0, space); | |||
String pkgList = grp.substring(space + 1); | |||
toExecute.createArgument().setValue("-group"); | |||
@@ -1799,7 +1844,7 @@ public class Javadoc extends Task { | |||
if (element instanceof TagArgument) { | |||
TagArgument ta = (TagArgument) element; | |||
File tagDir = ta.getDir(getProject()); | |||
if (tagDir == null ) { | |||
if (tagDir == null) { | |||
// The tag element is not used as a fileset, | |||
// but specifies the tag directly. | |||
toExecute.createArgument().setValue ("-tag"); | |||
@@ -1810,17 +1855,20 @@ public class Javadoc extends Task { | |||
DirectoryScanner tagDefScanner = ta.getDirectoryScanner(getProject()); | |||
String[] files = tagDefScanner.getIncludedFiles(); | |||
for (int i = 0; i < files.length; i++) { | |||
File tagDefFile = new File( tagDir, files[i] ); | |||
File tagDefFile = new File(tagDir, files[i]); | |||
try { | |||
BufferedReader in = new BufferedReader( new FileReader(tagDefFile) ); | |||
BufferedReader in | |||
= new BufferedReader(new FileReader(tagDefFile)); | |||
String line = null; | |||
while( (line = in.readLine()) != null ) { | |||
while ((line = in.readLine()) != null) { | |||
toExecute.createArgument().setValue ("-tag"); | |||
toExecute.createArgument().setValue (line); | |||
} | |||
in.close(); | |||
} catch( IOException ioe ) { | |||
throw new BuildException( "Couldn't read tag file from " + tagDefFile.getAbsolutePath(), ioe ); | |||
} catch (IOException ioe) { | |||
throw new BuildException("Couldn't read " | |||
+ " tag file from " | |||
+ tagDefFile.getAbsolutePath(), ioe ); | |||
} | |||
} | |||
} | |||
@@ -1952,7 +2000,9 @@ public class Javadoc extends Task { | |||
try { | |||
out.close(); | |||
err.close(); | |||
} catch (IOException e) {} | |||
} catch (IOException e) { | |||
// ignore | |||
} | |||
} | |||
} | |||
@@ -96,117 +96,150 @@ public abstract class ConditionBase extends ProjectComponent { | |||
* | |||
* @since 1.1 | |||
*/ | |||
public void addAvailable(Available a) {conditions.addElement(a);} | |||
public void addAvailable(Available a) { | |||
conditions.addElement(a); | |||
} | |||
/** | |||
* Add an <checksum> condition. | |||
* | |||
* @since 1.4, Ant 1.5 | |||
*/ | |||
public void addChecksum(Checksum c) {conditions.addElement(c);} | |||
public void addChecksum(Checksum c) { | |||
conditions.addElement(c); | |||
} | |||
/** | |||
* Add an <uptodate> condition. | |||
* | |||
* @since 1.1 | |||
*/ | |||
public void addUptodate(UpToDate u) {conditions.addElement(u);} | |||
public void addUptodate(UpToDate u) { | |||
conditions.addElement(u); | |||
} | |||
/** | |||
* Add an <not> condition "container". | |||
* | |||
* @since 1.1 | |||
*/ | |||
public void addNot(Not n) {conditions.addElement(n);} | |||
public void addNot(Not n) { | |||
conditions.addElement(n); | |||
} | |||
/** | |||
* Add an <and> condition "container". | |||
* | |||
* @since 1.1 | |||
*/ | |||
public void addAnd(And a) {conditions.addElement(a);} | |||
public void addAnd(And a) { | |||
conditions.addElement(a); | |||
} | |||
/** | |||
* Add an <or> condition "container". | |||
* | |||
* @since 1.1 | |||
*/ | |||
public void addOr(Or o) {conditions.addElement(o);} | |||
public void addOr(Or o) { | |||
conditions.addElement(o); | |||
} | |||
/** | |||
* Add an <equals> condition. | |||
* | |||
* @since 1.1 | |||
*/ | |||
public void addEquals(Equals e) {conditions.addElement(e);} | |||
public void addEquals(Equals e) { | |||
conditions.addElement(e); | |||
} | |||
/** | |||
* Add an <os> condition. | |||
* | |||
* @since 1.1 | |||
*/ | |||
public void addOs(Os o) {conditions.addElement(o);} | |||
public void addOs(Os o) { | |||
conditions.addElement(o); | |||
} | |||
/** | |||
* Add an <isset> condition. | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
public void addIsSet(IsSet i) {conditions.addElement(i);} | |||
public void addIsSet(IsSet i) { | |||
conditions.addElement(i); | |||
} | |||
/** | |||
* Add an <http> condition. | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
public void addHttp(Http h) {conditions.addElement(h);} | |||
public void addHttp(Http h) { | |||
conditions.addElement(h); | |||
} | |||
/** | |||
* Add a <socket> condition. | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
public void addSocket(Socket s) {conditions.addElement(s);} | |||
public void addSocket(Socket s) { | |||
conditions.addElement(s); | |||
} | |||
/** | |||
* Add a <filesmatch> condition. | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
public void addFilesMatch(FilesMatch test) {conditions.addElement(test);} | |||
public void addFilesMatch(FilesMatch test) { | |||
conditions.addElement(test); | |||
} | |||
/** | |||
* Add a <contains> condition. | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
public void addContains(Contains test) {conditions.addElement(test);} | |||
public void addContains(Contains test) { | |||
conditions.addElement(test); | |||
} | |||
/** | |||
* Add a <istrue> condition. | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
public void addIsTrue(IsTrue test) {conditions.addElement(test);} | |||
public void addIsTrue(IsTrue test) { | |||
conditions.addElement(test); | |||
} | |||
/** | |||
* Add a <isfalse> condition. | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
public void addIsFalse(IsFalse test) {conditions.addElement(test);} | |||
public void addIsFalse(IsFalse test) { | |||
conditions.addElement(test); | |||
} | |||
/** | |||
* Add an <isreference> condition. | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
public void addIsReference(IsReference i) {conditions.addElement(i);} | |||
public void addIsReference(IsReference i) { | |||
conditions.addElement(i); | |||
} | |||
/** | |||
* Add an arbitary condition | |||
* @since Ant 1.6 | |||
*/ | |||
public void add(Condition c) {conditions.addElement(c);} | |||
public void add(Condition c) { | |||
conditions.addElement(c); | |||
} | |||
} |
@@ -1,7 +1,7 @@ | |||
/* | |||
* The Apache Software License, Version 1.1 | |||
* | |||
* Copyright (c) 2000,2002-2003 The Apache Software Foundation. All rights | |||
* Copyright (c) 2000,2002-2003 The Apache Software Foundation. All rights | |||
* reserved. | |||
* | |||
* Redistribution and use in source and binary forms, with or without | |||
@@ -67,34 +67,34 @@ import org.apache.tools.ant.types.Path; | |||
/** | |||
* Precompiles JSP's using WebLogic's JSP compiler (weblogic.jspc). | |||
* | |||
* | |||
* @author <a href="mailto:avik@aviksengupta.com">Avik Sengupta</a> http://www.webteksoftware.com | |||
* | |||
* | |||
* Tested only on Weblogic 4.5.1 - NT4.0 and Solaris 5.7 | |||
* | |||
* | |||
* required attributes | |||
* src : root of source tree for JSP, ie, the document root for your weblogic server | |||
* dest : root of destination directory, what you have set as WorkingDir in the weblogic properties | |||
* package : start package name under which your JSP's would be compiled | |||
* | |||
* | |||
* other attributes | |||
* classpath | |||
* | |||
* | |||
* A classpath should be set which contains the weblogic classes as well as all application classes | |||
* referenced by the JSP. The system classpath is also appended when the jspc is called, so you may | |||
* referenced by the JSP. The system classpath is also appended when the jspc is called, so you may | |||
* choose to put everything in the classpath while calling Ant. However, since presumably the JSP's will reference | |||
* classes being build by Ant, it would be better to explicitly add the classpath in the task | |||
* | |||
* | |||
* The task checks timestamps on the JSP's and the generated classes, and compiles | |||
* only those files that have changed. | |||
* | |||
* It follows the weblogic naming convention of putting classes in | |||
* only those files that have changed. | |||
* | |||
* It follows the weblogic naming convention of putting classes in | |||
* <b> _dirName/_fileName.class for dirname/fileName.jsp </b> | |||
* | |||
* Limitation: It compiles the files thru the Classic compiler only. | |||
* | |||
* Limitation: It compiles the files thru the Classic compiler only. | |||
* Limitation: Since it is my experience that weblogic jspc throws out of memory error on being given too | |||
* many files at one go, it is called multiple times with one jsp file each. | |||
* | |||
* many files at one go, it is called multiple times with one jsp file each. | |||
* | |||
* <pre> | |||
* example | |||
* <target name="jspcompile" depends="compile"> | |||
@@ -103,43 +103,52 @@ import org.apache.tools.ant.types.Path; | |||
* <pathelement location="${weblogic.classpath}" /> | |||
* <pathelement path="${compile.dest}" /> | |||
* </classpath> | |||
* | |||
* | |||
* </wljspc> | |||
* </target> | |||
* </pre> | |||
* | |||
* | |||
*/ | |||
public class WLJspc extends MatchingTask { | |||
//TODO Test on other versions of weblogic | |||
//TODO add more attributes to the task, to take care of all jspc options | |||
//TODO Test on Unix | |||
private File destinationDirectory; //root of compiled files tree | |||
private File sourceDirectory; // root of source files tree | |||
private String destinationPackage; //package under which resultant classes will reside | |||
private Path compileClasspath; //classpath used to compile the jsp files. | |||
/** root of compiled files tree */ | |||
private File destinationDirectory; | |||
/** root of source files tree */ | |||
private File sourceDirectory; | |||
/** package under which resultant classes will reside */ | |||
private String destinationPackage; | |||
/** classpath used to compile the jsp files. */ | |||
private Path compileClasspath; | |||
//private String compilerPath; //fully qualified name for the compiler executable | |||
private String pathToPackage = ""; | |||
private Vector filesToDo = new Vector(); | |||
public void execute() throws BuildException { | |||
if (!destinationDirectory.isDirectory()) { | |||
throw new BuildException("destination directory " + destinationDirectory.getPath() + | |||
" is not valid"); | |||
throw new BuildException("destination directory " | |||
+ destinationDirectory.getPath() + " is not valid"); | |||
} | |||
if (!sourceDirectory.isDirectory()) { | |||
throw new BuildException("src directory " + sourceDirectory.getPath() + | |||
" is not valid"); | |||
throw new BuildException("src directory " | |||
+ sourceDirectory.getPath() + " is not valid"); | |||
} | |||
if (destinationPackage == null) { | |||
throw new BuildException("package attribute must be present.", getLocation()); | |||
throw new BuildException("package attribute must be present.", | |||
getLocation()); | |||
} | |||
pathToPackage | |||
= this.destinationPackage.replace('.', File.separatorChar); | |||
// get all the files in the sourceDirectory | |||
@@ -149,30 +158,30 @@ public class WLJspc extends MatchingTask { | |||
if (compileClasspath == null) { | |||
compileClasspath = new Path(getProject()); | |||
} | |||
compileClasspath = compileClasspath.concatSystemClasspath(); | |||
String[] files = ds.getIncludedFiles(); | |||
//Weblogic.jspc calls System.exit() ... have to fork | |||
// 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) | |||
// 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) getProject().createTask("java"); | |||
helperTask.setFork(true); | |||
helperTask.setClassname("weblogic.jspc"); | |||
helperTask.setTaskName(getTaskName()); | |||
String[] args = new String[12]; | |||
File jspFile = null; | |||
String parents = ""; | |||
int j = 0; | |||
//XXX this array stuff is a remnant of prev trials.. gotta remove. | |||
//XXX this array stuff is a remnant of prev trials.. gotta remove. | |||
args[j++] = "-d"; | |||
args[j++] = destinationDirectory.getAbsolutePath().trim(); | |||
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 | |||
//Call compiler as class... dont want to fork again | |||
//Use classic compiler -- can be parameterised? | |||
args[j++] = "-compilerclass"; | |||
args[j++] = "sun.tools.javac.Main"; | |||
@@ -181,14 +190,14 @@ public class WLJspc extends MatchingTask { | |||
// Am i missing something about the Java task?? | |||
args[j++] = "-classpath"; | |||
args[j++] = compileClasspath.toString(); | |||
this.scanDir(files); | |||
log("Compiling " + filesToDo.size() + " JSP files"); | |||
for (int i = 0; i < filesToDo.size(); i++) { | |||
//XXX | |||
// All this to get package according to weblogic standards | |||
// Can be written better... this is too hacky! | |||
// Can be written better... this is too hacky! | |||
// Careful.. similar code in scanDir , but slightly different!! | |||
String filename = (String) filesToDo.elementAt(i); | |||
jspFile = new File(filename); | |||
@@ -200,27 +209,27 @@ public class WLJspc extends MatchingTask { | |||
} else { | |||
args[j + 1] = destinationPackage; | |||
} | |||
args[j + 2] = sourceDirectory + File.separator + filename; | |||
helperTask.clearArgs(); | |||
for (int x = 0; x < j + 3; x++) { | |||
helperTask.createArg().setValue(args[x]); | |||
} | |||
helperTask.setClasspath(compileClasspath); | |||
if (helperTask.executeJava() != 0) { | |||
if (helperTask.executeJava() != 0) { | |||
log(filename + " failed to compile", Project.MSG_WARN); | |||
} | |||
} | |||
} | |||
/** | |||
* Set the classpath to be used for this compilation. | |||
* | |||
* | |||
*/ | |||
public void setClasspath(Path classpath) { | |||
if (compileClasspath == null) { | |||
@@ -242,38 +251,38 @@ public class WLJspc extends MatchingTask { | |||
/** | |||
* Set the directory containing the source jsp's | |||
* | |||
* | |||
* | |||
* @param dirName the directory containg the source jsp's | |||
*/ | |||
public void setSrc(File dirName) { | |||
sourceDirectory = dirName; | |||
} | |||
/** | |||
* Set the directory containing the source jsp's | |||
* | |||
* | |||
* | |||
* @param dirName the directory containg the source jsp's | |||
*/ | |||
public void setDest(File dirName) { | |||
destinationDirectory = dirName; | |||
} | |||
/** | |||
* Set the package under which the compiled classes go | |||
* | |||
* | |||
* @param packageName the package name for the clases | |||
*/ | |||
public void setPackage(String packageName) { | |||
destinationPackage = packageName; | |||
destinationPackage = packageName; | |||
} | |||
protected void scanDir(String files[]) { | |||
long now = (new Date()).getTime(); | |||
@@ -283,8 +292,8 @@ public class WLJspc extends MatchingTask { | |||
for (int i = 0; i < files.length; 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! | |||
// 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]); | |||
parents = jspFile.getParent(); | |||
@@ -294,17 +303,17 @@ public class WLJspc extends MatchingTask { | |||
} else { | |||
pack = pathToPackage; | |||
} | |||
String filePath = pack + File.separator + "_"; | |||
int startingIndex | |||
int startingIndex | |||
= files[i].lastIndexOf(File.separator) != -1 ? files[i].lastIndexOf(File.separator) + 1 : 0; | |||
int endingIndex = files[i].indexOf(".jsp"); | |||
if (endingIndex == -1) { | |||
log("Skipping " + files[i] + ". Not a JSP", | |||
log("Skipping " + files[i] + ". Not a JSP", | |||
Project.MSG_VERBOSE); | |||
continue; | |||
} | |||
filePath += files[i].substring(startingIndex, endingIndex); | |||
filePath += ".class"; | |||
File classFile = new File(this.destinationDirectory, filePath); | |||
@@ -314,14 +323,13 @@ public class WLJspc extends MatchingTask { | |||
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); | |||
} | |||
} | |||
} | |||
protected String replaceString(String inpString, String escapeChars, | |||
String replaceChars) { | |||
String localString = ""; | |||
@@ -74,7 +74,7 @@ import org.apache.tools.ant.Project; | |||
* @author <A href="mailto:martin@mvdb.net"> Martin van den Bemt </A> | |||
*/ | |||
public class FilterSet extends DataType implements Cloneable { | |||
/** | |||
* Individual filter component of filterset | |||
* | |||
@@ -83,10 +83,10 @@ public class FilterSet extends DataType implements Cloneable { | |||
public static class Filter { | |||
/** Token which will be replaced in the filter operation */ | |||
String token; | |||
/** The value which will replace the token in the filtering operation */ | |||
String value; | |||
/** | |||
* Constructor for the Filter object | |||
* | |||
@@ -97,13 +97,13 @@ public class FilterSet extends DataType implements Cloneable { | |||
this.token = token; | |||
this.value = value; | |||
} | |||
/** | |||
* No argument conmstructor | |||
*/ | |||
public Filter() { | |||
} | |||
/** | |||
* Sets the Token attribute of the Filter object | |||
* | |||
@@ -112,7 +112,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
public void setToken(String token) { | |||
this.token = token; | |||
} | |||
/** | |||
* Sets the Value attribute of the Filter object | |||
* | |||
@@ -121,7 +121,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
public void setValue(String value) { | |||
this.value = value; | |||
} | |||
/** | |||
* Gets the Token attribute of the Filter object | |||
* | |||
@@ -130,7 +130,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
public String getToken() { | |||
return token; | |||
} | |||
/** | |||
* Gets the Value attribute of the Filter object | |||
* | |||
@@ -140,20 +140,20 @@ public class FilterSet extends DataType implements Cloneable { | |||
return value; | |||
} | |||
} | |||
/** | |||
* The filtersfile nested element. | |||
* | |||
* @author Michael McCallum | |||
*/ | |||
public class FiltersFile { | |||
/** | |||
* Constructor for the Filter object | |||
*/ | |||
public FiltersFile() { | |||
} | |||
/** | |||
* Sets the file from which filters will be read. | |||
* | |||
@@ -163,24 +163,27 @@ public class FilterSet extends DataType implements Cloneable { | |||
readFiltersFromFile(file); | |||
} | |||
} | |||
/** The default token start string */ | |||
public static final String DEFAULT_TOKEN_START = "@"; | |||
/** The default token end string */ | |||
public static final String DEFAULT_TOKEN_END = "@"; | |||
private String startOfToken = DEFAULT_TOKEN_START; | |||
private String endOfToken = DEFAULT_TOKEN_END; | |||
/** | |||
* List of ordered filters and filter files. | |||
*/ | |||
private Vector filters = new Vector(); | |||
/** | |||
* Default constructor | |||
*/ | |||
public FilterSet() { | |||
} | |||
/** | |||
* Create a Filterset from another filterset | |||
* | |||
@@ -191,6 +194,11 @@ public class FilterSet extends DataType implements Cloneable { | |||
this.filters = (Vector) filterset.getFilters().clone(); | |||
} | |||
/** | |||
* Get the filters in the filter set | |||
* | |||
* @return a Vector of Filter instances | |||
*/ | |||
protected Vector getFilters() { | |||
if (isReference()) { | |||
return getRef().getFilters(); | |||
@@ -198,10 +206,15 @@ public class FilterSet extends DataType implements Cloneable { | |||
return filters; | |||
} | |||
/** | |||
* Get the referred filter set | |||
* | |||
* @return the filterset from the reference. | |||
*/ | |||
protected FilterSet getRef() { | |||
return (FilterSet) getCheckedRef(FilterSet.class, "filterset"); | |||
} | |||
/** | |||
* Gets the filter hash of the FilterSet. | |||
* | |||
@@ -216,7 +229,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
} | |||
return filterHash; | |||
} | |||
/** | |||
* set the file containing the filters for this filterset. | |||
* | |||
@@ -229,7 +242,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
} | |||
readFiltersFromFile(filtersFile); | |||
} | |||
/** | |||
* The string used to id the beginning of a token. | |||
* | |||
@@ -245,14 +258,19 @@ public class FilterSet extends DataType implements Cloneable { | |||
this.startOfToken = startOfToken; | |||
} | |||
/** | |||
* Get the begin token for this filterset | |||
* | |||
* @return the filter set's begin token for filtering | |||
*/ | |||
public String getBeginToken() { | |||
if (isReference()) { | |||
return getRef().getBeginToken(); | |||
} | |||
return startOfToken; | |||
} | |||
/** | |||
* The string used to id the end of a token. | |||
* | |||
@@ -268,14 +286,19 @@ public class FilterSet extends DataType implements Cloneable { | |||
this.endOfToken = endOfToken; | |||
} | |||
/** | |||
* Get the end token for this filterset | |||
* | |||
* @return the filter set's end token for replacement delimiting | |||
*/ | |||
public String getEndToken() { | |||
if (isReference()) { | |||
return getRef().getEndToken(); | |||
} | |||
return endOfToken; | |||
} | |||
/** | |||
* Read the filters from the given file. | |||
* | |||
@@ -289,7 +312,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
} | |||
if (!filtersFile.exists()) { | |||
throw new BuildException("Could not read filters from file " | |||
throw new BuildException("Could not read filters from file " | |||
+ filtersFile + " as it doesn't exist."); | |||
} | |||
@@ -300,7 +323,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
Properties props = new Properties(); | |||
in = new FileInputStream(filtersFile); | |||
props.load(in); | |||
Enumeration enum = props.propertyNames(); | |||
Vector filters = getFilters(); | |||
while (enum.hasMoreElements()) { | |||
@@ -309,22 +332,23 @@ public class FilterSet extends DataType implements Cloneable { | |||
filters.addElement(new Filter(strPropName, strValue)); | |||
} | |||
} catch (Exception e) { | |||
throw new BuildException("Could not read filters from file: " | |||
throw new BuildException("Could not read filters from file: " | |||
+ filtersFile); | |||
} finally { | |||
if (in != null) { | |||
try { | |||
in.close(); | |||
} catch (IOException ioex) { | |||
// ignore | |||
} | |||
} | |||
} | |||
} else { | |||
throw new BuildException("Must specify a file not a directory in " | |||
throw new BuildException("Must specify a file not a directory in " | |||
+ "the filtersfile attribute:" + filtersFile); | |||
} | |||
} | |||
/** | |||
* Does replacement on the given string with token matching. | |||
* This uses the defined begintoken and endtoken values which default to @ for both. | |||
@@ -336,7 +360,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
String beginToken = getBeginToken(); | |||
String endToken = getEndToken(); | |||
int index = line.indexOf(beginToken); | |||
if (index > -1) { | |||
Hashtable tokens = getFilterHash(); | |||
try { | |||
@@ -344,14 +368,14 @@ public class FilterSet extends DataType implements Cloneable { | |||
int i = 0; | |||
String token = null; | |||
String value = null; | |||
do { | |||
int endIndex = line.indexOf(endToken, | |||
int endIndex = line.indexOf(endToken, | |||
index + beginToken.length() + 1); | |||
if (endIndex == -1) { | |||
break; | |||
} | |||
token | |||
token | |||
= line.substring(index + beginToken.length(), endIndex); | |||
b.append(line.substring(i, index)); | |||
if (tokens.containsKey(token)) { | |||
@@ -360,10 +384,10 @@ public class FilterSet extends DataType implements Cloneable { | |||
// we have another token, let's parse it. | |||
value = replaceTokens(value, token); | |||
} | |||
log("Replacing: " + beginToken + token + endToken | |||
log("Replacing: " + beginToken + token + endToken | |||
+ " -> " + value, Project.MSG_VERBOSE); | |||
b.append(value); | |||
i = index + beginToken.length() + token.length() | |||
i = index + beginToken.length() + token.length() | |||
+ endToken.length(); | |||
} else { | |||
// just append beginToken and search further | |||
@@ -371,7 +395,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
i = index + beginToken.length(); | |||
} | |||
} while ((index = line.indexOf(beginToken, i)) > -1); | |||
b.append(line.substring(i)); | |||
return b.toString(); | |||
} catch (StringIndexOutOfBoundsException e) { | |||
@@ -381,12 +405,12 @@ public class FilterSet extends DataType implements Cloneable { | |||
return line; | |||
} | |||
} | |||
/** Contains a list of parsed tokens */ | |||
private Vector passedTokens; | |||
/** if a ducplicate token is found, this is set to true */ | |||
private boolean duplicateToken = false; | |||
/** | |||
* This parses tokens which point to tokens. | |||
* It also maintains a list of currently used tokens, so we cannot | |||
@@ -395,8 +419,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
* @param parent the parant token (= the token it was parsed from) | |||
*/ | |||
private String replaceTokens(String line, String parent) | |||
throws BuildException | |||
{ | |||
throws BuildException { | |||
if (passedTokens == null) { | |||
passedTokens = new Vector(); | |||
} | |||
@@ -405,8 +428,10 @@ public class FilterSet extends DataType implements Cloneable { | |||
StringBuffer sb = new StringBuffer(); | |||
sb.append("Inifinite loop in tokens. Currently known tokens : "); | |||
sb.append(passedTokens); | |||
sb.append("\nProblem token : "+getBeginToken()+parent+getEndToken()); | |||
sb.append(" called from "+getBeginToken()+passedTokens.lastElement()); | |||
sb.append("\nProblem token : " + getBeginToken() + parent | |||
+ getEndToken()); | |||
sb.append(" called from " + getBeginToken() | |||
+ passedTokens.lastElement()); | |||
sb.append(getEndToken()); | |||
System.out.println(sb.toString()); | |||
return parent; | |||
@@ -416,24 +441,24 @@ public class FilterSet extends DataType implements Cloneable { | |||
if (value.indexOf(getBeginToken()) == -1 && !duplicateToken) { | |||
duplicateToken = false; | |||
passedTokens = null; | |||
} else if(duplicateToken) { | |||
} else if (duplicateToken) { | |||
// should always be the case... | |||
if (passedTokens.size() > 0) { | |||
value = (String) passedTokens.lastElement(); | |||
passedTokens.removeElementAt(passedTokens.size()-1); | |||
passedTokens.removeElementAt(passedTokens.size() - 1); | |||
if (passedTokens.size() == 0) { | |||
value = getBeginToken()+value+getEndToken(); | |||
value = getBeginToken() + value + getEndToken(); | |||
duplicateToken = false; | |||
} | |||
} | |||
} | |||
return value; | |||
} | |||
/** | |||
* Create a new filter | |||
* | |||
* @param the filter to be added | |||
* @param filter the filter to be added | |||
*/ | |||
public void addFilter(Filter filter) { | |||
if (isReference()) { | |||
@@ -441,7 +466,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
} | |||
filters.addElement(filter); | |||
} | |||
/** | |||
* Create a new FiltersFile | |||
* | |||
@@ -453,7 +478,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
} | |||
return new FiltersFile(); | |||
} | |||
/** | |||
* Add a new filter made from the given token and value. | |||
* | |||
@@ -466,7 +491,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
} | |||
filters.addElement(new Filter(token, value)); | |||
} | |||
/** | |||
* Add a Filterset to this filter set | |||
* | |||
@@ -480,7 +505,7 @@ public class FilterSet extends DataType implements Cloneable { | |||
filters.addElement(e.nextElement()); | |||
} | |||
} | |||
/** | |||
* Test to see if this filter set it empty. | |||
* | |||
@@ -490,6 +515,13 @@ public class FilterSet extends DataType implements Cloneable { | |||
return getFilters().size() > 0; | |||
} | |||
/** | |||
* clone the filterset | |||
* | |||
* @return a deep clone of this filterset | |||
* | |||
* @throws BuildException if the clone cannot be performed. | |||
*/ | |||
public Object clone() throws BuildException { | |||
if (isReference()) { | |||
return ((FilterSet) getRef()).clone(); | |||
@@ -506,6 +538,6 @@ public class FilterSet extends DataType implements Cloneable { | |||
} | |||
} | |||