git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272320 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -160,7 +160,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| (url == null)) { | (url == null)) { | ||||
| try { | try { | ||||
| File pathComponent | File pathComponent | ||||
| = (File)pathComponents.elementAt(pathElementsIndex); | |||||
| = (File) pathComponents.elementAt(pathElementsIndex); | |||||
| url = getResourceURL(pathComponent, this.resourceName); | url = getResourceURL(pathComponent, this.resourceName); | ||||
| pathElementsIndex++; | pathElementsIndex++; | ||||
| } catch (BuildException e) { | } catch (BuildException e) { | ||||
| @@ -649,7 +649,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| Enumeration e = pathComponents.elements(); | Enumeration e = pathComponents.elements(); | ||||
| while (e.hasMoreElements() && stream == null) { | while (e.hasMoreElements() && stream == null) { | ||||
| File pathComponent = (File)e.nextElement(); | |||||
| File pathComponent = (File) e.nextElement(); | |||||
| stream = getResourceStream(pathComponent, name); | stream = getResourceStream(pathComponent, name); | ||||
| } | } | ||||
| return stream; | return stream; | ||||
| @@ -699,7 +699,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| } | } | ||||
| } else { | } else { | ||||
| // is the zip file in the cache | // is the zip file in the cache | ||||
| ZipFile zipFile = (ZipFile)zipFiles.get(file); | |||||
| ZipFile zipFile = (ZipFile) zipFiles.get(file); | |||||
| if (zipFile == null) { | if (zipFile == null) { | ||||
| zipFile = new ZipFile(file); | zipFile = new ZipFile(file); | ||||
| zipFiles.put(file, zipFile); | zipFiles.put(file, zipFile); | ||||
| @@ -741,7 +741,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| boolean useParentFirst = parentFirst; | boolean useParentFirst = parentFirst; | ||||
| for (Enumeration e = systemPackages.elements(); e.hasMoreElements();) { | for (Enumeration e = systemPackages.elements(); e.hasMoreElements();) { | ||||
| String packageName = (String)e.nextElement(); | |||||
| String packageName = (String) e.nextElement(); | |||||
| if (resourceName.startsWith(packageName)) { | if (resourceName.startsWith(packageName)) { | ||||
| useParentFirst = true; | useParentFirst = true; | ||||
| break; | break; | ||||
| @@ -749,7 +749,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| } | } | ||||
| for (Enumeration e = loaderPackages.elements(); e.hasMoreElements();) { | for (Enumeration e = loaderPackages.elements(); e.hasMoreElements();) { | ||||
| String packageName = (String)e.nextElement(); | |||||
| String packageName = (String) e.nextElement(); | |||||
| if (resourceName.startsWith(packageName)) { | if (resourceName.startsWith(packageName)) { | ||||
| useParentFirst = false; | useParentFirst = false; | ||||
| break; | break; | ||||
| @@ -789,7 +789,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| // it or wasn't consulted. | // it or wasn't consulted. | ||||
| Enumeration e = pathComponents.elements(); | Enumeration e = pathComponents.elements(); | ||||
| while (e.hasMoreElements() && url == null) { | while (e.hasMoreElements() && url == null) { | ||||
| File pathComponent = (File)e.nextElement(); | |||||
| File pathComponent = (File) e.nextElement(); | |||||
| url = getResourceURL(pathComponent, name); | url = getResourceURL(pathComponent, name); | ||||
| if (url != null) { | if (url != null) { | ||||
| log("Resource " + name | log("Resource " + name | ||||
| @@ -859,7 +859,7 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| ZipFile zipFile = (ZipFile)zipFiles.get(file); | |||||
| ZipFile zipFile = (ZipFile) zipFiles.get(file); | |||||
| if (zipFile == null) { | if (zipFile == null) { | ||||
| zipFile = new ZipFile(file); | zipFile = new ZipFile(file); | ||||
| zipFiles.put(file, zipFile); | zipFiles.put(file, zipFile); | ||||
| @@ -993,18 +993,16 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| Object[] args | Object[] args | ||||
| = new Object[] {classname, classData, new Integer(0), | = new Object[] {classname, classData, new Integer(0), | ||||
| new Integer(classData.length), domain}; | new Integer(classData.length), domain}; | ||||
| return (Class)defineClassProtectionDomain.invoke(this, args); | |||||
| return (Class) defineClassProtectionDomain.invoke(this, args); | |||||
| } catch (InvocationTargetException ite) { | } catch (InvocationTargetException ite) { | ||||
| Throwable t = ite.getTargetException(); | Throwable t = ite.getTargetException(); | ||||
| if (t instanceof ClassFormatError) { | if (t instanceof ClassFormatError) { | ||||
| throw (ClassFormatError)t; | |||||
| throw (ClassFormatError) t; | |||||
| } else if (t instanceof NoClassDefFoundError) { | } else if (t instanceof NoClassDefFoundError) { | ||||
| throw (NoClassDefFoundError)t; | |||||
| } | |||||
| else if (t instanceof SecurityException) { | |||||
| throw (SecurityException)t; | |||||
| } | |||||
| else { | |||||
| throw (NoClassDefFoundError) t; | |||||
| } else if (t instanceof SecurityException) { | |||||
| throw (SecurityException) t; | |||||
| } else { | |||||
| throw new IOException(t.toString()); | throw new IOException(t.toString()); | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -1053,17 +1051,15 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| try { | try { | ||||
| Enumeration e = pathComponents.elements(); | Enumeration e = pathComponents.elements(); | ||||
| while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
| File pathComponent = (File)e.nextElement(); | |||||
| File pathComponent = (File) e.nextElement(); | |||||
| try { | try { | ||||
| stream = getResourceStream(pathComponent, classFilename); | stream = getResourceStream(pathComponent, classFilename); | ||||
| if (stream != null) { | if (stream != null) { | ||||
| return getClassFromStream(stream, name); | return getClassFromStream(stream, name); | ||||
| } | } | ||||
| } | |||||
| catch (SecurityException se) { | |||||
| } catch (SecurityException se) { | |||||
| throw se; | throw se; | ||||
| } | |||||
| catch (IOException ioe) { | |||||
| } catch (IOException ioe) { | |||||
| // ioe.printStackTrace(); | // ioe.printStackTrace(); | ||||
| log("Exception reading component " + pathComponent , | log("Exception reading component " + pathComponent , | ||||
| Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
| @@ -1110,8 +1106,8 @@ public class AntClassLoader extends ClassLoader implements BuildListener { | |||||
| public void cleanup() { | public void cleanup() { | ||||
| pathComponents = null; | pathComponents = null; | ||||
| project = null; | project = null; | ||||
| for (Enumeration e = zipFiles.elements(); e.hasMoreElements(); ) { | |||||
| ZipFile zipFile = (ZipFile)e.nextElement(); | |||||
| for (Enumeration e = zipFiles.elements(); e.hasMoreElements();) { | |||||
| ZipFile zipFile = (ZipFile) e.nextElement(); | |||||
| try { | try { | ||||
| zipFile.close(); | zipFile.close(); | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| @@ -88,7 +88,8 @@ public class DemuxOutputStream extends OutputStream { | |||||
| } | } | ||||
| /** Maximum buffer size. */ | /** Maximum buffer size. */ | ||||
| private final static int MAX_SIZE = 1024; | |||||
| private static final int MAX_SIZE = 1024; | |||||
| /** Mapping from thread to buffer (Thread to BufferInfo). */ | /** Mapping from thread to buffer (Thread to BufferInfo). */ | ||||
| private Hashtable buffers = new Hashtable(); | private Hashtable buffers = new Hashtable(); | ||||
| @@ -124,7 +125,7 @@ public class DemuxOutputStream extends OutputStream { | |||||
| */ | */ | ||||
| private BufferInfo getBufferInfo() { | private BufferInfo getBufferInfo() { | ||||
| Thread current = Thread.currentThread(); | Thread current = Thread.currentThread(); | ||||
| BufferInfo bufferInfo = (BufferInfo)buffers.get(current); | |||||
| BufferInfo bufferInfo = (BufferInfo) buffers.get(current); | |||||
| if (bufferInfo == null) { | if (bufferInfo == null) { | ||||
| bufferInfo = new BufferInfo(); | bufferInfo = new BufferInfo(); | ||||
| bufferInfo.buffer = new ByteArrayOutputStream(); | bufferInfo.buffer = new ByteArrayOutputStream(); | ||||
| @@ -139,11 +140,10 @@ public class DemuxOutputStream extends OutputStream { | |||||
| */ | */ | ||||
| private void resetBufferInfo() { | private void resetBufferInfo() { | ||||
| Thread current = Thread.currentThread(); | Thread current = Thread.currentThread(); | ||||
| BufferInfo bufferInfo = (BufferInfo)buffers.get(current); | |||||
| BufferInfo bufferInfo = (BufferInfo) buffers.get(current); | |||||
| try { | try { | ||||
| bufferInfo.buffer.close(); | bufferInfo.buffer.close(); | ||||
| } | |||||
| catch (IOException e) { | |||||
| } catch (IOException e) { | |||||
| // Shouldn't happen | // Shouldn't happen | ||||
| } | } | ||||
| bufferInfo.buffer = new ByteArrayOutputStream(); | bufferInfo.buffer = new ByteArrayOutputStream(); | ||||
| @@ -166,7 +166,7 @@ public class DemuxOutputStream extends OutputStream { | |||||
| * @exception IOException if the data cannot be written to the stream | * @exception IOException if the data cannot be written to the stream | ||||
| */ | */ | ||||
| public void write(int cc) throws IOException { | public void write(int cc) throws IOException { | ||||
| final byte c = (byte)cc; | |||||
| final byte c = (byte) cc; | |||||
| BufferInfo bufferInfo = getBufferInfo(); | BufferInfo bufferInfo = getBufferInfo(); | ||||
| if ((c == '\n') || (c == '\r')) { | if ((c == '\n') || (c == '\r')) { | ||||
| @@ -147,7 +147,7 @@ public class DirectoryScanner implements FileScanner { | |||||
| * | * | ||||
| * @see #addDefaultExcludes() | * @see #addDefaultExcludes() | ||||
| */ | */ | ||||
| protected final static String[] DEFAULTEXCLUDES = { | |||||
| protected static final String[] DEFAULTEXCLUDES = { | |||||
| "**/*~", | "**/*~", | ||||
| "**/#*#", | "**/#*#", | ||||
| "**/.#*", | "**/.#*", | ||||
| @@ -264,17 +264,17 @@ public class DirectoryScanner implements FileScanner { | |||||
| Vector strDirs = tokenizePath (str); | Vector strDirs = tokenizePath (str); | ||||
| int patIdxStart = 0; | int patIdxStart = 0; | ||||
| int patIdxEnd = patDirs.size()-1; | |||||
| int patIdxEnd = patDirs.size() - 1; | |||||
| int strIdxStart = 0; | int strIdxStart = 0; | ||||
| int strIdxEnd = strDirs.size()-1; | |||||
| int strIdxEnd = strDirs.size() - 1; | |||||
| // up to first '**' | // up to first '**' | ||||
| while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | ||||
| String patDir = (String)patDirs.elementAt(patIdxStart); | |||||
| String patDir = (String) patDirs.elementAt(patIdxStart); | |||||
| if (patDir.equals("**")) { | if (patDir.equals("**")) { | ||||
| break; | break; | ||||
| } | } | ||||
| if (!match(patDir,(String)strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||||
| if (!match(patDir, (String) strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| patIdxStart++; | patIdxStart++; | ||||
| @@ -322,7 +322,8 @@ public class DirectoryScanner implements FileScanner { | |||||
| * @return <code>true</code> if the pattern matches against the string, | * @return <code>true</code> if the pattern matches against the string, | ||||
| * or <code>false</code> otherwise. | * or <code>false</code> otherwise. | ||||
| */ | */ | ||||
| protected static boolean matchPath(String pattern, String str, boolean isCaseSensitive) { | |||||
| protected static boolean matchPath(String pattern, String str, | |||||
| boolean isCaseSensitive) { | |||||
| // When str starts with a File.separator, pattern has to start with a | // When str starts with a File.separator, pattern has to start with a | ||||
| // File.separator. | // File.separator. | ||||
| // When pattern starts with a File.separator, str has to start with a | // When pattern starts with a File.separator, str has to start with a | ||||
| @@ -336,17 +337,17 @@ public class DirectoryScanner implements FileScanner { | |||||
| Vector strDirs = tokenizePath (str); | Vector strDirs = tokenizePath (str); | ||||
| int patIdxStart = 0; | int patIdxStart = 0; | ||||
| int patIdxEnd = patDirs.size()-1; | |||||
| int patIdxEnd = patDirs.size() - 1; | |||||
| int strIdxStart = 0; | int strIdxStart = 0; | ||||
| int strIdxEnd = strDirs.size()-1; | |||||
| int strIdxEnd = strDirs.size() - 1; | |||||
| // up to first '**' | // up to first '**' | ||||
| while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | ||||
| String patDir = (String)patDirs.elementAt(patIdxStart); | |||||
| String patDir = (String) patDirs.elementAt(patIdxStart); | |||||
| if (patDir.equals("**")) { | if (patDir.equals("**")) { | ||||
| break; | break; | ||||
| } | } | ||||
| if (!match(patDir,(String)strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||||
| if (!match(patDir, (String) strDirs.elementAt(strIdxStart), isCaseSensitive)) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| patIdxStart++; | patIdxStart++; | ||||
| @@ -369,11 +370,11 @@ public class DirectoryScanner implements FileScanner { | |||||
| // up to last '**' | // up to last '**' | ||||
| while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { | ||||
| String patDir = (String)patDirs.elementAt(patIdxEnd); | |||||
| String patDir = (String) patDirs.elementAt(patIdxEnd); | |||||
| if (patDir.equals("**")) { | if (patDir.equals("**")) { | ||||
| break; | break; | ||||
| } | } | ||||
| if (!match(patDir,(String)strDirs.elementAt(strIdxEnd), isCaseSensitive)) { | |||||
| if (!match(patDir, (String) strDirs.elementAt(strIdxEnd), isCaseSensitive)) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| patIdxEnd--; | patIdxEnd--; | ||||
| @@ -391,33 +392,35 @@ public class DirectoryScanner implements FileScanner { | |||||
| while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { | while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { | ||||
| int patIdxTmp = -1; | int patIdxTmp = -1; | ||||
| for (int i = patIdxStart+1; i <= patIdxEnd; i++) { | |||||
| for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { | |||||
| if (patDirs.elementAt(i).equals("**")) { | if (patDirs.elementAt(i).equals("**")) { | ||||
| patIdxTmp = i; | patIdxTmp = i; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (patIdxTmp == patIdxStart+1) { | |||||
| if (patIdxTmp == patIdxStart + 1) { | |||||
| // '**/**' situation, so skip one | // '**/**' situation, so skip one | ||||
| patIdxStart++; | patIdxStart++; | ||||
| continue; | continue; | ||||
| } | } | ||||
| // Find the pattern between padIdxStart & padIdxTmp in str between | // Find the pattern between padIdxStart & padIdxTmp in str between | ||||
| // strIdxStart & strIdxEnd | // strIdxStart & strIdxEnd | ||||
| int patLength = (patIdxTmp-patIdxStart-1); | |||||
| int strLength = (strIdxEnd-strIdxStart+1); | |||||
| int patLength = (patIdxTmp - patIdxStart - 1); | |||||
| int strLength = (strIdxEnd - strIdxStart + 1); | |||||
| int foundIdx = -1; | int foundIdx = -1; | ||||
| strLoop: | strLoop: | ||||
| for (int i = 0; i <= strLength - patLength; i++) { | for (int i = 0; i <= strLength - patLength; i++) { | ||||
| for (int j = 0; j < patLength; j++) { | for (int j = 0; j < patLength; j++) { | ||||
| String subPat = (String)patDirs.elementAt(patIdxStart+j+1); | |||||
| String subStr = (String)strDirs.elementAt(strIdxStart+i+j); | |||||
| if (!match(subPat,subStr, isCaseSensitive)) { | |||||
| String subPat | |||||
| = (String) patDirs.elementAt(patIdxStart + j + 1); | |||||
| String subStr | |||||
| = (String) strDirs.elementAt(strIdxStart + i + j); | |||||
| if (!match(subPat, subStr, isCaseSensitive)) { | |||||
| continue strLoop; | continue strLoop; | ||||
| } | } | ||||
| } | } | ||||
| foundIdx = strIdxStart+i; | |||||
| foundIdx = strIdxStart + i; | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -426,7 +429,7 @@ strLoop: | |||||
| } | } | ||||
| patIdxStart = patIdxTmp; | patIdxStart = patIdxTmp; | ||||
| strIdxStart = foundIdx+patLength; | |||||
| strIdxStart = foundIdx + patLength; | |||||
| } | } | ||||
| for (int i = patIdxStart; i <= patIdxEnd; i++) { | for (int i = patIdxStart; i <= patIdxEnd; i++) { | ||||
| @@ -473,13 +476,14 @@ strLoop: | |||||
| * @return <code>true</code> if the string matches against the pattern, | * @return <code>true</code> if the string matches against the pattern, | ||||
| * or <code>false</code> otherwise. | * or <code>false</code> otherwise. | ||||
| */ | */ | ||||
| protected static boolean match(String pattern, String str, boolean isCaseSensitive) { | |||||
| protected static boolean match(String pattern, String str, | |||||
| boolean isCaseSensitive) { | |||||
| char[] patArr = pattern.toCharArray(); | char[] patArr = pattern.toCharArray(); | ||||
| char[] strArr = str.toCharArray(); | char[] strArr = str.toCharArray(); | ||||
| int patIdxStart = 0; | int patIdxStart = 0; | ||||
| int patIdxEnd = patArr.length-1; | |||||
| int patIdxEnd = patArr.length - 1; | |||||
| int strIdxStart = 0; | int strIdxStart = 0; | ||||
| int strIdxEnd = strArr.length-1; | |||||
| int strIdxEnd = strArr.length - 1; | |||||
| char ch; | char ch; | ||||
| boolean containsStar = false; | boolean containsStar = false; | ||||
| @@ -515,7 +519,7 @@ strLoop: | |||||
| } | } | ||||
| // Process characters before first star | // Process characters before first star | ||||
| while((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) { | |||||
| while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) { | |||||
| if (ch != '?') { | if (ch != '?') { | ||||
| if (isCaseSensitive && ch != strArr[strIdxStart]) { | if (isCaseSensitive && ch != strArr[strIdxStart]) { | ||||
| return false;// Character mismatch | return false;// Character mismatch | ||||
| @@ -540,7 +544,7 @@ strLoop: | |||||
| } | } | ||||
| // Process characters after last star | // Process characters after last star | ||||
| while((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) { | |||||
| while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) { | |||||
| if (ch != '?') { | if (ch != '?') { | ||||
| if (isCaseSensitive && ch != strArr[strIdxEnd]) { | if (isCaseSensitive && ch != strArr[strIdxEnd]) { | ||||
| return false;// Character mismatch | return false;// Character mismatch | ||||
| @@ -568,38 +572,39 @@ strLoop: | |||||
| // always to a '*'. | // always to a '*'. | ||||
| while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { | while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { | ||||
| int patIdxTmp = -1; | int patIdxTmp = -1; | ||||
| for (int i = patIdxStart+1; i <= patIdxEnd; i++) { | |||||
| for (int i = patIdxStart + 1; i <= patIdxEnd; i++) { | |||||
| if (patArr[i] == '*') { | if (patArr[i] == '*') { | ||||
| patIdxTmp = i; | patIdxTmp = i; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (patIdxTmp == patIdxStart+1) { | |||||
| if (patIdxTmp == patIdxStart + 1) { | |||||
| // Two stars next to each other, skip the first one. | // Two stars next to each other, skip the first one. | ||||
| patIdxStart++; | patIdxStart++; | ||||
| continue; | continue; | ||||
| } | } | ||||
| // Find the pattern between padIdxStart & padIdxTmp in str between | // Find the pattern between padIdxStart & padIdxTmp in str between | ||||
| // strIdxStart & strIdxEnd | // strIdxStart & strIdxEnd | ||||
| int patLength = (patIdxTmp-patIdxStart-1); | |||||
| int strLength = (strIdxEnd-strIdxStart+1); | |||||
| int patLength = (patIdxTmp - patIdxStart - 1); | |||||
| int strLength = (strIdxEnd - strIdxStart + 1); | |||||
| int foundIdx = -1; | int foundIdx = -1; | ||||
| strLoop: | strLoop: | ||||
| for (int i = 0; i <= strLength - patLength; i++) { | for (int i = 0; i <= strLength - patLength; i++) { | ||||
| for (int j = 0; j < patLength; j++) { | for (int j = 0; j < patLength; j++) { | ||||
| ch = patArr[patIdxStart+j+1]; | |||||
| ch = patArr[patIdxStart + j + 1]; | |||||
| if (ch != '?') { | if (ch != '?') { | ||||
| if (isCaseSensitive && ch != strArr[strIdxStart+i+j]) { | |||||
| if (isCaseSensitive | |||||
| && ch != strArr[strIdxStart + i + j]) { | |||||
| continue strLoop; | continue strLoop; | ||||
| } | } | ||||
| if (!isCaseSensitive && Character.toUpperCase(ch) != | if (!isCaseSensitive && Character.toUpperCase(ch) != | ||||
| Character.toUpperCase(strArr[strIdxStart+i+j])) { | |||||
| Character.toUpperCase(strArr[strIdxStart + i + j])) { | |||||
| continue strLoop; | continue strLoop; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| foundIdx = strIdxStart+i; | |||||
| foundIdx = strIdxStart + i; | |||||
| break; | break; | ||||
| } | } | ||||
| @@ -608,7 +613,7 @@ strLoop: | |||||
| } | } | ||||
| patIdxStart = patIdxTmp; | patIdxStart = patIdxTmp; | ||||
| strIdxStart = foundIdx+patLength; | |||||
| strIdxStart = foundIdx + patLength; | |||||
| } | } | ||||
| // All characters in the string are used. Check if only '*'s are left | // All characters in the string are used. Check if only '*'s are left | ||||
| @@ -631,7 +636,7 @@ strLoop: | |||||
| */ | */ | ||||
| private static Vector tokenizePath (String path) { | private static Vector tokenizePath (String path) { | ||||
| Vector ret = new Vector(); | Vector ret = new Vector(); | ||||
| StringTokenizer st = new StringTokenizer(path,File.separator); | |||||
| StringTokenizer st = new StringTokenizer(path, File.separator); | |||||
| while (st.hasMoreTokens()) { | while (st.hasMoreTokens()) { | ||||
| ret.addElement(st.nextToken()); | ret.addElement(st.nextToken()); | ||||
| } | } | ||||
| @@ -648,7 +653,7 @@ strLoop: | |||||
| * Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
| */ | */ | ||||
| public void setBasedir(String basedir) { | public void setBasedir(String basedir) { | ||||
| setBasedir(new File(basedir.replace('/',File.separatorChar).replace('\\',File.separatorChar))); | |||||
| setBasedir(new File(basedir.replace('/', File.separatorChar).replace('\\', File.separatorChar))); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -702,7 +707,7 @@ strLoop: | |||||
| this.includes = new String[includes.length]; | this.includes = new String[includes.length]; | ||||
| for (int i = 0; i < includes.length; i++) { | for (int i = 0; i < includes.length; i++) { | ||||
| String pattern; | String pattern; | ||||
| pattern = includes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); | |||||
| pattern = includes[i].replace('/', File.separatorChar).replace('\\', File.separatorChar); | |||||
| if (pattern.endsWith(File.separator)) { | if (pattern.endsWith(File.separator)) { | ||||
| pattern += "**"; | pattern += "**"; | ||||
| } | } | ||||
| @@ -730,7 +735,7 @@ strLoop: | |||||
| this.excludes = new String[excludes.length]; | this.excludes = new String[excludes.length]; | ||||
| for (int i = 0; i < excludes.length; i++) { | for (int i = 0; i < excludes.length; i++) { | ||||
| String pattern; | String pattern; | ||||
| pattern = excludes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); | |||||
| pattern = excludes[i].replace('/', File.separatorChar).replace('\\', File.separatorChar); | |||||
| if (pattern.endsWith(File.separator)) { | if (pattern.endsWith(File.separator)) { | ||||
| pattern += "**"; | pattern += "**"; | ||||
| } | } | ||||
| @@ -818,17 +823,17 @@ strLoop: | |||||
| String[] notIncl = new String[dirsNotIncluded.size()]; | String[] notIncl = new String[dirsNotIncluded.size()]; | ||||
| dirsNotIncluded.copyInto(notIncl); | dirsNotIncluded.copyInto(notIncl); | ||||
| for (int i=0; i<excl.length; i++) { | |||||
| for (int i = 0; i < excl.length; i++) { | |||||
| if (!couldHoldIncluded(excl[i])) { | if (!couldHoldIncluded(excl[i])) { | ||||
| scandir(new File(basedir, excl[i]), | scandir(new File(basedir, excl[i]), | ||||
| excl[i]+File.separator, false); | |||||
| excl[i] + File.separator, false); | |||||
| } | } | ||||
| } | } | ||||
| for (int i=0; i<notIncl.length; i++) { | |||||
| for (int i = 0; i < notIncl.length; i++) { | |||||
| if (!couldHoldIncluded(notIncl[i])) { | if (!couldHoldIncluded(notIncl[i])) { | ||||
| scandir(new File(basedir, notIncl[i]), | scandir(new File(basedir, notIncl[i]), | ||||
| notIncl[i]+File.separator, false); | |||||
| notIncl[i] + File.separator, false); | |||||
| } | } | ||||
| } | } | ||||
| @@ -871,31 +876,31 @@ strLoop: | |||||
| } | } | ||||
| for (int i = 0; i < newfiles.length; i++) { | for (int i = 0; i < newfiles.length; i++) { | ||||
| String name = vpath+newfiles[i]; | |||||
| File file = new File(dir,newfiles[i]); | |||||
| String name = vpath + newfiles[i]; | |||||
| File file = new File(dir, newfiles[i]); | |||||
| if (file.isDirectory()) { | if (file.isDirectory()) { | ||||
| if (isIncluded(name)) { | if (isIncluded(name)) { | ||||
| if (!isExcluded(name)) { | if (!isExcluded(name)) { | ||||
| dirsIncluded.addElement(name); | dirsIncluded.addElement(name); | ||||
| if (fast) { | if (fast) { | ||||
| scandir(file, name+File.separator, fast); | |||||
| scandir(file, name + File.separator, fast); | |||||
| } | } | ||||
| } else { | } else { | ||||
| everythingIncluded = false; | everythingIncluded = false; | ||||
| dirsExcluded.addElement(name); | dirsExcluded.addElement(name); | ||||
| if (fast && couldHoldIncluded(name)) { | if (fast && couldHoldIncluded(name)) { | ||||
| scandir(file, name+File.separator, fast); | |||||
| scandir(file, name + File.separator, fast); | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| everythingIncluded = false; | everythingIncluded = false; | ||||
| dirsNotIncluded.addElement(name); | dirsNotIncluded.addElement(name); | ||||
| if (fast && couldHoldIncluded(name)) { | if (fast && couldHoldIncluded(name)) { | ||||
| scandir(file, name+File.separator, fast); | |||||
| scandir(file, name + File.separator, fast); | |||||
| } | } | ||||
| } | } | ||||
| if (!fast) { | if (!fast) { | ||||
| scandir(file, name+File.separator, fast); | |||||
| scandir(file, name + File.separator, fast); | |||||
| } | } | ||||
| } else if (file.isFile()) { | } else if (file.isFile()) { | ||||
| if (isIncluded(name)) { | if (isIncluded(name)) { | ||||
| @@ -940,7 +945,7 @@ strLoop: | |||||
| */ | */ | ||||
| protected boolean couldHoldIncluded(String name) { | protected boolean couldHoldIncluded(String name) { | ||||
| for (int i = 0; i < includes.length; i++) { | for (int i = 0; i < includes.length; i++) { | ||||
| if (matchPatternStart(includes[i],name, isCaseSensitive)) { | |||||
| if (matchPatternStart(includes[i], name, isCaseSensitive)) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -957,7 +962,7 @@ strLoop: | |||||
| */ | */ | ||||
| protected boolean isExcluded(String name) { | protected boolean isExcluded(String name) { | ||||
| for (int i = 0; i < excludes.length; i++) { | for (int i = 0; i < excludes.length; i++) { | ||||
| if (matchPath(excludes[i],name, isCaseSensitive)) { | |||||
| if (matchPath(excludes[i], name, isCaseSensitive)) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -976,7 +981,7 @@ strLoop: | |||||
| int count = filesIncluded.size(); | int count = filesIncluded.size(); | ||||
| String[] files = new String[count]; | String[] files = new String[count]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| files[i] = (String)filesIncluded.elementAt(i); | |||||
| files[i] = (String) filesIncluded.elementAt(i); | |||||
| } | } | ||||
| return files; | return files; | ||||
| } | } | ||||
| @@ -996,7 +1001,7 @@ strLoop: | |||||
| int count = filesNotIncluded.size(); | int count = filesNotIncluded.size(); | ||||
| String[] files = new String[count]; | String[] files = new String[count]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| files[i] = (String)filesNotIncluded.elementAt(i); | |||||
| files[i] = (String) filesNotIncluded.elementAt(i); | |||||
| } | } | ||||
| return files; | return files; | ||||
| } | } | ||||
| @@ -1017,7 +1022,7 @@ strLoop: | |||||
| int count = filesExcluded.size(); | int count = filesExcluded.size(); | ||||
| String[] files = new String[count]; | String[] files = new String[count]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| files[i] = (String)filesExcluded.elementAt(i); | |||||
| files[i] = (String) filesExcluded.elementAt(i); | |||||
| } | } | ||||
| return files; | return files; | ||||
| } | } | ||||
| @@ -1034,7 +1039,7 @@ strLoop: | |||||
| int count = dirsIncluded.size(); | int count = dirsIncluded.size(); | ||||
| String[] directories = new String[count]; | String[] directories = new String[count]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| directories[i] = (String)dirsIncluded.elementAt(i); | |||||
| directories[i] = (String) dirsIncluded.elementAt(i); | |||||
| } | } | ||||
| return directories; | return directories; | ||||
| } | } | ||||
| @@ -1054,7 +1059,7 @@ strLoop: | |||||
| int count = dirsNotIncluded.size(); | int count = dirsNotIncluded.size(); | ||||
| String[] directories = new String[count]; | String[] directories = new String[count]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| directories[i] = (String)dirsNotIncluded.elementAt(i); | |||||
| directories[i] = (String) dirsNotIncluded.elementAt(i); | |||||
| } | } | ||||
| return directories; | return directories; | ||||
| } | } | ||||
| @@ -1075,7 +1080,7 @@ strLoop: | |||||
| int count = dirsExcluded.size(); | int count = dirsExcluded.size(); | ||||
| String[] directories = new String[count]; | String[] directories = new String[count]; | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| directories[i] = (String)dirsExcluded.elementAt(i); | |||||
| directories[i] = (String) dirsExcluded.elementAt(i); | |||||
| } | } | ||||
| return directories; | return directories; | ||||
| } | } | ||||
| @@ -1088,10 +1093,10 @@ strLoop: | |||||
| String[] newExcludes; | String[] newExcludes; | ||||
| newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; | newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; | ||||
| if (excludesLength > 0) { | if (excludesLength > 0) { | ||||
| System.arraycopy(excludes,0,newExcludes,0,excludesLength); | |||||
| System.arraycopy(excludes, 0, newExcludes, 0, excludesLength); | |||||
| } | } | ||||
| for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { | for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { | ||||
| newExcludes[i+excludesLength] = DEFAULTEXCLUDES[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); | |||||
| newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i].replace('/', File.separatorChar).replace('\\', File.separatorChar); | |||||
| } | } | ||||
| excludes = newExcludes; | excludes = newExcludes; | ||||
| } | } | ||||
| @@ -140,7 +140,7 @@ public interface FileScanner { | |||||
| * incorrectly (i.e. if it is <code>null</code>, doesn't exist, | * incorrectly (i.e. if it is <code>null</code>, doesn't exist, | ||||
| * or isn't a directory). | * or isn't a directory). | ||||
| */ | */ | ||||
| void scan(); | |||||
| void scan() throws IllegalStateException; | |||||
| /** | /** | ||||
| * Sets the base directory to be scanned. This is the directory which is | * Sets the base directory to be scanned. This is the directory which is | ||||
| @@ -135,7 +135,7 @@ public class IntrospectionHelper implements BuildListener { | |||||
| Class[] wrappers = {Boolean.class, Byte.class, Character.class, | Class[] wrappers = {Boolean.class, Byte.class, Character.class, | ||||
| Short.class, Integer.class, Long.class, | Short.class, Integer.class, Long.class, | ||||
| Float.class, Double.class}; | Float.class, Double.class}; | ||||
| for (int i=0; i < primitives.length; i++) { | |||||
| for (int i = 0; i < primitives.length; i++) { | |||||
| PRIMITIVE_TYPE_MAP.put (primitives[i], wrappers[i]); | PRIMITIVE_TYPE_MAP.put (primitives[i], wrappers[i]); | ||||
| } | } | ||||
| } | } | ||||
| @@ -204,7 +204,7 @@ public class IntrospectionHelper implements BuildListener { | |||||
| this.bean = bean; | this.bean = bean; | ||||
| Method[] methods = bean.getMethods(); | Method[] methods = bean.getMethods(); | ||||
| for (int i=0; i<methods.length; i++) { | |||||
| for (int i = 0; i < methods.length; i++) { | |||||
| final Method m = methods[i]; | final Method m = methods[i]; | ||||
| final String name = m.getName(); | final String name = m.getName(); | ||||
| Class returnType = m.getReturnType(); | Class returnType = m.getReturnType(); | ||||
| @@ -392,7 +392,8 @@ public class IntrospectionHelper implements BuildListener { | |||||
| public void setAttribute(Project p, Object element, String attributeName, | public void setAttribute(Project p, Object element, String attributeName, | ||||
| String value) | String value) | ||||
| throws BuildException { | throws BuildException { | ||||
| AttributeSetter as = (AttributeSetter) attributeSetters.get(attributeName); | |||||
| AttributeSetter as | |||||
| = (AttributeSetter) attributeSetters.get(attributeName); | |||||
| if (as == null) { | if (as == null) { | ||||
| String msg = p.getElementName(element) + | String msg = p.getElementName(element) + | ||||
| //String msg = "Class " + element.getClass().getName() + | //String msg = "Class " + element.getClass().getName() + | ||||
| @@ -434,11 +435,10 @@ public class IntrospectionHelper implements BuildListener { | |||||
| throws BuildException { | throws BuildException { | ||||
| if (addText == null) { | if (addText == null) { | ||||
| // Element doesn't handle text content | // Element doesn't handle text content | ||||
| if ( text.trim().length() == 0 ) { | |||||
| if (text.trim().length() == 0) { | |||||
| // Only whitespace - ignore | // Only whitespace - ignore | ||||
| return; | return; | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| // Not whitespace - fail | // Not whitespace - fail | ||||
| String msg = project.getElementName(element) + | String msg = project.getElementName(element) + | ||||
| " doesn't support nested text data."; | " doesn't support nested text data."; | ||||
| @@ -480,8 +480,8 @@ public class IntrospectionHelper implements BuildListener { | |||||
| * element instance, or if the creating method | * element instance, or if the creating method | ||||
| * fails. | * fails. | ||||
| */ | */ | ||||
| public Object createElement(Project project, Object parent, String elementName) | |||||
| throws BuildException { | |||||
| public Object createElement(Project project, Object parent, | |||||
| String elementName) throws BuildException { | |||||
| NestedCreator nc = (NestedCreator) nestedCreators.get(elementName); | NestedCreator nc = (NestedCreator) nestedCreators.get(elementName); | ||||
| if (nc == null) { | if (nc == null) { | ||||
| String msg = project.getElementName(parent) + | String msg = project.getElementName(parent) + | ||||
| @@ -529,12 +529,12 @@ public class IntrospectionHelper implements BuildListener { | |||||
| * | * | ||||
| * @exception BuildException if the storage method fails. | * @exception BuildException if the storage method fails. | ||||
| */ | */ | ||||
| public void storeElement(Project project, Object parent, Object child, String elementName) | |||||
| throws BuildException { | |||||
| public void storeElement(Project project, Object parent, Object child, | |||||
| String elementName) throws BuildException { | |||||
| if (elementName == null) { | if (elementName == null) { | ||||
| return; | return; | ||||
| } | } | ||||
| NestedStorer ns = (NestedStorer)nestedStorers.get(elementName); | |||||
| NestedStorer ns = (NestedStorer) nestedStorers.get(elementName); | |||||
| if (ns == null) { | if (ns == null) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -663,7 +663,8 @@ public class IntrospectionHelper implements BuildListener { | |||||
| */ | */ | ||||
| private AttributeSetter createAttributeSetter(final Method m, | private AttributeSetter createAttributeSetter(final Method m, | ||||
| Class arg) { | Class arg) { | ||||
| // use wrappers for primitive classes, e.g. int and Integer are treated identically | |||||
| // use wrappers for primitive classes, e.g. int and | |||||
| // Integer are treated identically | |||||
| final Class reflectedArg = PRIMITIVE_TYPE_MAP.containsKey (arg) | final Class reflectedArg = PRIMITIVE_TYPE_MAP.containsKey (arg) | ||||
| ? (Class) PRIMITIVE_TYPE_MAP.get(arg) : arg; | ? (Class) PRIMITIVE_TYPE_MAP.get(arg) : arg; | ||||
| @@ -685,8 +686,8 @@ public class IntrospectionHelper implements BuildListener { | |||||
| } | } | ||||
| }; | }; | ||||
| // boolean and Boolean get special treatment because we have a nice method | |||||
| // in Project | |||||
| // boolean and Boolean get special treatment because we | |||||
| // have a nice method in Project | |||||
| } else if (java.lang.Boolean.class.equals(reflectedArg)) { | } else if (java.lang.Boolean.class.equals(reflectedArg)) { | ||||
| return new AttributeSetter() { | return new AttributeSetter() { | ||||
| public void set(Project p, Object parent, String value) | public void set(Project p, Object parent, String value) | ||||
| @@ -737,7 +738,7 @@ public class IntrospectionHelper implements BuildListener { | |||||
| throws InvocationTargetException, IllegalAccessException, BuildException { | throws InvocationTargetException, IllegalAccessException, BuildException { | ||||
| try { | try { | ||||
| org.apache.tools.ant.types.EnumeratedAttribute ea = | org.apache.tools.ant.types.EnumeratedAttribute ea = | ||||
| (org.apache.tools.ant.types.EnumeratedAttribute)reflectedArg.newInstance(); | |||||
| (org.apache.tools.ant.types.EnumeratedAttribute) reflectedArg.newInstance(); | |||||
| ea.setValue(value); | ea.setValue(value); | ||||
| m.invoke(parent, new EnumeratedAttribute[] {ea}); | m.invoke(parent, new EnumeratedAttribute[] {ea}); | ||||
| } catch (InstantiationException ie) { | } catch (InstantiationException ie) { | ||||
| @@ -792,8 +793,7 @@ public class IntrospectionHelper implements BuildListener { | |||||
| * | * | ||||
| * @return a description of the element type | * @return a description of the element type | ||||
| */ | */ | ||||
| protected String getElementName(Project project, Object element) | |||||
| { | |||||
| protected String getElementName(Project project, Object element) { | |||||
| return project.getElementName(element); | return project.getElementName(element); | ||||
| } | } | ||||
| @@ -69,7 +69,7 @@ public class Location { | |||||
| private int columnNumber; | private int columnNumber; | ||||
| /** Location to use when one is needed but no information is available */ | /** Location to use when one is needed but no information is available */ | ||||
| public final static Location UNKNOWN_LOCATION = new Location(); | |||||
| public static final Location UNKNOWN_LOCATION = new Location(); | |||||
| /** | /** | ||||
| * Creates an "unknown" location. | * Creates an "unknown" location. | ||||
| @@ -79,7 +79,7 @@ import java.util.Enumeration; | |||||
| public class Main { | public class Main { | ||||
| /** The default build file name. */ | /** The default build file name. */ | ||||
| public final static String DEFAULT_BUILD_FILENAME = "build.xml"; | |||||
| public static final String DEFAULT_BUILD_FILENAME = "build.xml"; | |||||
| /** Our current message output status. Follows Project.MSG_XXX. */ | /** Our current message output status. Follows Project.MSG_XXX. */ | ||||
| private int msgOutputLevel = Project.MSG_INFO; | private int msgOutputLevel = Project.MSG_INFO; | ||||
| @@ -174,7 +174,7 @@ public class Main { | |||||
| if (additionalUserProperties != null) { | if (additionalUserProperties != null) { | ||||
| for (Enumeration e = additionalUserProperties.keys(); | for (Enumeration e = additionalUserProperties.keys(); | ||||
| e.hasMoreElements(); ) { | |||||
| e.hasMoreElements();) { | |||||
| String key = (String) e.nextElement(); | String key = (String) e.nextElement(); | ||||
| String property = additionalUserProperties.getProperty(key); | String property = additionalUserProperties.getProperty(key); | ||||
| m.definedProps.put(key, property); | m.definedProps.put(key, property); | ||||
| @@ -334,8 +334,7 @@ public class Main { | |||||
| } | } | ||||
| try { | try { | ||||
| loggerClassname = args[++i]; | loggerClassname = args[++i]; | ||||
| } | |||||
| catch (ArrayIndexOutOfBoundsException aioobe) { | |||||
| } catch (ArrayIndexOutOfBoundsException aioobe) { | |||||
| System.out.println("You must specify a classname when " + | System.out.println("You must specify a classname when " + | ||||
| "using the -logger argument"); | "using the -logger argument"); | ||||
| return; | return; | ||||
| @@ -410,8 +409,7 @@ public class Main { | |||||
| try { | try { | ||||
| fis = new FileInputStream(filename); | fis = new FileInputStream(filename); | ||||
| props.load(fis); | props.load(fis); | ||||
| } | |||||
| catch (IOException e) { | |||||
| } catch (IOException e) { | |||||
| System.out.println("Could not load property file " | System.out.println("Could not load property file " | ||||
| + filename + ": " + e.getMessage()); | + filename + ": " + e.getMessage()); | ||||
| } finally { | } finally { | ||||
| @@ -537,8 +535,8 @@ public class Main { | |||||
| // use a system manager that prevents from System.exit() | // use a system manager that prevents from System.exit() | ||||
| // only in JDK > 1.1 | // only in JDK > 1.1 | ||||
| SecurityManager oldsm = null; | SecurityManager oldsm = null; | ||||
| if ( !Project.JAVA_1_0.equals(Project.getJavaVersion()) && | |||||
| !Project.JAVA_1_1.equals(Project.getJavaVersion()) ){ | |||||
| if (!Project.JAVA_1_0.equals(Project.getJavaVersion()) && | |||||
| !Project.JAVA_1_1.equals(Project.getJavaVersion())){ | |||||
| oldsm = System.getSecurityManager(); | oldsm = System.getSecurityManager(); | ||||
| //SecurityManager can not be installed here for backwards | //SecurityManager can not be installed here for backwards | ||||
| @@ -559,13 +557,13 @@ public class Main { | |||||
| // set user-define properties | // set user-define properties | ||||
| Enumeration e = definedProps.keys(); | Enumeration e = definedProps.keys(); | ||||
| while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
| String arg = (String)e.nextElement(); | |||||
| String value = (String)definedProps.get(arg); | |||||
| String arg = (String) e.nextElement(); | |||||
| String value = (String) definedProps.get(arg); | |||||
| project.setUserProperty(arg, value); | project.setUserProperty(arg, value); | ||||
| } | } | ||||
| project.setUserProperty("ant.file", | project.setUserProperty("ant.file", | ||||
| buildFile.getAbsolutePath() ); | |||||
| buildFile.getAbsolutePath()); | |||||
| // first use the ProjectHelper to create the project object | // first use the ProjectHelper to create the project object | ||||
| // from the given build file. | // from the given build file. | ||||
| @@ -585,7 +583,7 @@ public class Main { | |||||
| if (projectHelp) { | if (projectHelp) { | ||||
| printDescription(project); | printDescription(project); | ||||
| printTargets(project, msgOutputLevel > Project.MSG_INFO ); | |||||
| printTargets(project, msgOutputLevel > Project.MSG_INFO); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -595,8 +593,7 @@ public class Main { | |||||
| } | } | ||||
| project.executeTargets(targets); | project.executeTargets(targets); | ||||
| } | |||||
| finally { | |||||
| } finally { | |||||
| // put back the original security manager | // put back the original security manager | ||||
| //The following will never eval to true. (PD) | //The following will never eval to true. (PD) | ||||
| if (oldsm != null){ | if (oldsm != null){ | ||||
| @@ -606,16 +603,13 @@ public class Main { | |||||
| System.setOut(out); | System.setOut(out); | ||||
| System.setErr(err); | System.setErr(err); | ||||
| } | } | ||||
| } | |||||
| catch (RuntimeException exc) { | |||||
| } catch (RuntimeException exc) { | |||||
| error = exc; | error = exc; | ||||
| throw exc; | throw exc; | ||||
| } | |||||
| catch (Error err) { | |||||
| } catch (Error err) { | |||||
| error = err; | error = err; | ||||
| throw err; | throw err; | ||||
| } | |||||
| finally { | |||||
| } finally { | |||||
| if (!projectHelp) { | if (!projectHelp) { | ||||
| project.fireBuildFinished(error); | project.fireBuildFinished(error); | ||||
| } | } | ||||
| @@ -640,8 +634,7 @@ public class Main { | |||||
| BuildListener listener = | BuildListener listener = | ||||
| (BuildListener) Class.forName(className).newInstance(); | (BuildListener) Class.forName(className).newInstance(); | ||||
| project.addBuildListener(listener); | project.addBuildListener(listener); | ||||
| } | |||||
| catch (Throwable exc) { | |||||
| } catch (Throwable exc) { | |||||
| throw new BuildException("Unable to instantiate listener " | throw new BuildException("Unable to instantiate listener " | ||||
| + className, exc); | + className, exc); | ||||
| } | } | ||||
| @@ -662,21 +655,19 @@ public class Main { | |||||
| BuildLogger logger = null; | BuildLogger logger = null; | ||||
| if (loggerClassname != null) { | if (loggerClassname != null) { | ||||
| try { | try { | ||||
| logger = (BuildLogger)(Class.forName(loggerClassname).newInstance()); | |||||
| } | |||||
| catch (ClassCastException e) { | |||||
| logger = (BuildLogger) (Class.forName(loggerClassname).newInstance()); | |||||
| } catch (ClassCastException e) { | |||||
| System.err.println("The specified logger class " | System.err.println("The specified logger class " | ||||
| + loggerClassname | + loggerClassname | ||||
| + " does not implement the BuildLogger interface"); | + " does not implement the BuildLogger interface"); | ||||
| throw new RuntimeException(); | throw new RuntimeException(); | ||||
| } | |||||
| catch (Exception e) { | |||||
| } catch (Exception e) { | |||||
| System.err.println("Unable to instantiate specified logger " | System.err.println("Unable to instantiate specified logger " | ||||
| + "class " + loggerClassname + " : " + e.getClass().getName()); | |||||
| + "class " + loggerClassname + " : " | |||||
| + e.getClass().getName()); | |||||
| throw new RuntimeException(); | throw new RuntimeException(); | ||||
| } | } | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| logger = new DefaultLogger(); | logger = new DefaultLogger(); | ||||
| } | } | ||||
| @@ -801,7 +792,7 @@ public class Main { | |||||
| Vector subNames = new Vector(); | Vector subNames = new Vector(); | ||||
| while (ptargets.hasMoreElements()) { | while (ptargets.hasMoreElements()) { | ||||
| currentTarget = (Target)ptargets.nextElement(); | |||||
| currentTarget = (Target) ptargets.nextElement(); | |||||
| targetName = currentTarget.getName(); | targetName = currentTarget.getName(); | ||||
| targetDescription = currentTarget.getDescription(); | targetDescription = currentTarget.getDescription(); | ||||
| // maintain a sorted list of targets | // maintain a sorted list of targets | ||||
| @@ -827,7 +818,7 @@ public class Main { | |||||
| String defaultTarget = project.getDefaultTarget(); | String defaultTarget = project.getDefaultTarget(); | ||||
| if (defaultTarget != null && !"".equals(defaultTarget)) { | if (defaultTarget != null && !"".equals(defaultTarget)) { | ||||
| // shouldn't need to check but... | // shouldn't need to check but... | ||||
| System.out.println( "Default target: " + defaultTarget); | |||||
| System.out.println("Default target: " + defaultTarget); | |||||
| } | } | ||||
| } | } | ||||
| @@ -844,7 +835,7 @@ public class Main { | |||||
| private static int findTargetPosition(Vector names, String name) { | private static int findTargetPosition(Vector names, String name) { | ||||
| int res = names.size(); | int res = names.size(); | ||||
| for (int i = 0; i < names.size() && res == names.size(); i++) { | for (int i = 0; i < names.size() && res == names.size(); i++) { | ||||
| if (name.compareTo((String)names.elementAt(i)) < 0) { | |||||
| if (name.compareTo((String) names.elementAt(i)) < 0) { | |||||
| res = i; | res = i; | ||||
| } | } | ||||
| } | } | ||||
| @@ -884,7 +875,7 @@ public class Main { | |||||
| msg.append(" "); | msg.append(" "); | ||||
| msg.append(names.elementAt(i)); | msg.append(names.elementAt(i)); | ||||
| if (descriptions != null) { | if (descriptions != null) { | ||||
| msg.append(spaces.substring(0, maxlen - ((String)names.elementAt(i)).length() + 2)); | |||||
| msg.append(spaces.substring(0, maxlen - ((String) names.elementAt(i)).length() + 2)); | |||||
| msg.append(descriptions.elementAt(i)); | msg.append(descriptions.elementAt(i)); | ||||
| } | } | ||||
| msg.append(lSep); | msg.append(lSep); | ||||
| @@ -107,17 +107,17 @@ public class NoBannerLogger extends DefaultLogger { | |||||
| */ | */ | ||||
| public void messageLogged(BuildEvent event) { | public void messageLogged(BuildEvent event) { | ||||
| if( event.getPriority() > msgOutputLevel || | |||||
| null == event.getMessage() || | |||||
| "".equals( event.getMessage().trim() ) ) { | |||||
| return; | |||||
| if (event.getPriority() > msgOutputLevel | |||||
| || null == event.getMessage() | |||||
| || "".equals(event.getMessage().trim())) { | |||||
| return; | |||||
| } | } | ||||
| if( null != targetName ) { | |||||
| if (null != targetName) { | |||||
| out.println(StringUtils.LINE_SEP + targetName + ":"); | out.println(StringUtils.LINE_SEP + targetName + ":"); | ||||
| targetName = null; | targetName = null; | ||||
| } | } | ||||
| super.messageLogged( event ); | |||||
| super.messageLogged(event); | |||||
| } | } | ||||
| } | } | ||||
| @@ -104,8 +104,7 @@ public class PathTokenizer { | |||||
| // For NetWare, use the boolean=true mode, so we can use delimiter | // For NetWare, use the boolean=true mode, so we can use delimiter | ||||
| // information to make a better decision later. | // information to make a better decision later. | ||||
| tokenizer = new StringTokenizer(path, ":;", true); | tokenizer = new StringTokenizer(path, ":;", true); | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| // on Windows and Unix, we can ignore delimiters and still have | // on Windows and Unix, we can ignore delimiters and still have | ||||
| // enough information to tokenize correctly. | // enough information to tokenize correctly. | ||||
| tokenizer = new StringTokenizer(path, ":;", false); | tokenizer = new StringTokenizer(path, ":;", false); | ||||
| @@ -142,8 +141,7 @@ public class PathTokenizer { | |||||
| if (lookahead != null) { | if (lookahead != null) { | ||||
| token = lookahead; | token = lookahead; | ||||
| lookahead = null; | lookahead = null; | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| token = tokenizer.nextToken().trim(); | token = tokenizer.nextToken().trim(); | ||||
| } | } | ||||
| @@ -159,14 +157,12 @@ public class PathTokenizer { | |||||
| // starts with a slash or backslash, so we know this is a | // starts with a slash or backslash, so we know this is a | ||||
| // drive spec | // drive spec | ||||
| token += ":" + nextToken; | token += ":" + nextToken; | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| // store the token just read for next time | // store the token just read for next time | ||||
| lookahead = nextToken; | lookahead = nextToken; | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| // we are on NetWare, tokenizing is handled a little differently, | // we are on NetWare, tokenizing is handled a little differently, | ||||
| // due to the fact that NetWare has multiple-character volume names. | // due to the fact that NetWare has multiple-character volume names. | ||||
| if (token.equals(File.pathSeparator)) { | if (token.equals(File.pathSeparator)) { | ||||
| @@ -186,15 +182,13 @@ public class PathTokenizer { | |||||
| String oneMore = tokenizer.nextToken().trim(); | String oneMore = tokenizer.nextToken().trim(); | ||||
| if (!oneMore.equals(File.pathSeparator)) { | if (!oneMore.equals(File.pathSeparator)) { | ||||
| token += ":" + oneMore; | token += ":" + oneMore; | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| token += ":"; | token += ":"; | ||||
| } | } | ||||
| } | } | ||||
| // implicit else: ignore the ':' since we have either a | // implicit else: ignore the ':' since we have either a | ||||
| // UNIX or a relative path | // UNIX or a relative path | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| // store the token just read for next time | // store the token just read for next time | ||||
| lookahead = nextToken; | lookahead = nextToken; | ||||
| } | } | ||||
| @@ -88,42 +88,42 @@ import org.apache.tools.ant.util.JavaEnvUtils; | |||||
| public class Project { | public class Project { | ||||
| /** Message priority of "error". */ | /** Message priority of "error". */ | ||||
| public final static int MSG_ERR = 0; | |||||
| public static final int MSG_ERR = 0; | |||||
| /** Message priority of "warning". */ | /** Message priority of "warning". */ | ||||
| public final static int MSG_WARN = 1; | |||||
| public static final int MSG_WARN = 1; | |||||
| /** Message priority of "information". */ | /** Message priority of "information". */ | ||||
| public final static int MSG_INFO = 2; | |||||
| public static final int MSG_INFO = 2; | |||||
| /** Message priority of "verbose". */ | /** Message priority of "verbose". */ | ||||
| public final static int MSG_VERBOSE = 3; | |||||
| public static final int MSG_VERBOSE = 3; | |||||
| /** Message priority of "debug". */ | /** Message priority of "debug". */ | ||||
| public final static int MSG_DEBUG = 4; | |||||
| public static final int MSG_DEBUG = 4; | |||||
| /** | /** | ||||
| * Constant for the "visiting" state, used when | * Constant for the "visiting" state, used when | ||||
| * traversing a DFS of target dependencies. | * traversing a DFS of target dependencies. | ||||
| */ | */ | ||||
| private final static String VISITING = "VISITING"; | |||||
| private static final String VISITING = "VISITING"; | |||||
| /** | /** | ||||
| * Constant for the "visited" state, used when | * Constant for the "visited" state, used when | ||||
| * traversing a DFS of target dependencies. | * traversing a DFS of target dependencies. | ||||
| */ | */ | ||||
| private final static String VISITED = "VISITED"; | |||||
| private static final String VISITED = "VISITED"; | |||||
| /** Version constant for Java 1.0 */ | /** Version constant for Java 1.0 */ | ||||
| public final static String JAVA_1_0 = JavaEnvUtils.JAVA_1_0; | |||||
| public static final String JAVA_1_0 = JavaEnvUtils.JAVA_1_0; | |||||
| /** Version constant for Java 1.1 */ | /** Version constant for Java 1.1 */ | ||||
| public final static String JAVA_1_1 = JavaEnvUtils.JAVA_1_1; | |||||
| public static final String JAVA_1_1 = JavaEnvUtils.JAVA_1_1; | |||||
| /** Version constant for Java 1.2 */ | /** Version constant for Java 1.2 */ | ||||
| public final static String JAVA_1_2 = JavaEnvUtils.JAVA_1_2; | |||||
| public static final String JAVA_1_2 = JavaEnvUtils.JAVA_1_2; | |||||
| /** Version constant for Java 1.3 */ | /** Version constant for Java 1.3 */ | ||||
| public final static String JAVA_1_3 = JavaEnvUtils.JAVA_1_3; | |||||
| public static final String JAVA_1_3 = JavaEnvUtils.JAVA_1_3; | |||||
| /** Version constant for Java 1.4 */ | /** Version constant for Java 1.4 */ | ||||
| public final static String JAVA_1_4 = JavaEnvUtils.JAVA_1_4; | |||||
| public static final String JAVA_1_4 = JavaEnvUtils.JAVA_1_4; | |||||
| /** Default filter start token. */ | /** Default filter start token. */ | ||||
| public final static String TOKEN_START = FilterSet.DEFAULT_TOKEN_START; | |||||
| public static final String TOKEN_START = FilterSet.DEFAULT_TOKEN_START; | |||||
| /** Default filter end token. */ | /** Default filter end token. */ | ||||
| public final static String TOKEN_END = FilterSet.DEFAULT_TOKEN_END; | |||||
| public static final String TOKEN_END = FilterSet.DEFAULT_TOKEN_END; | |||||
| /** Name of this project. */ | /** Name of this project. */ | ||||
| private String name; | private String name; | ||||
| @@ -676,7 +676,7 @@ public class Project { | |||||
| + " is not a directory"); | + " is not a directory"); | ||||
| } | } | ||||
| this.baseDir = baseDir; | this.baseDir = baseDir; | ||||
| setPropertyInternal( "basedir", this.baseDir.getPath()); | |||||
| setPropertyInternal("basedir", this.baseDir.getPath()); | |||||
| String msg = "Project base dir set to: " + this.baseDir; | String msg = "Project base dir set to: " + this.baseDir; | ||||
| log(msg, MSG_VERBOSE); | log(msg, MSG_VERBOSE); | ||||
| } | } | ||||
| @@ -768,7 +768,7 @@ public class Project { | |||||
| */ | */ | ||||
| public void addTaskDefinition(String taskName, Class taskClass) | public void addTaskDefinition(String taskName, Class taskClass) | ||||
| throws BuildException { | throws BuildException { | ||||
| Class old = (Class)taskClassDefinitions.get(taskName); | |||||
| Class old = (Class) taskClassDefinitions.get(taskName); | |||||
| if (null != old) { | if (null != old) { | ||||
| if (old.equals(taskClass)) { | if (old.equals(taskClass)) { | ||||
| log("Ignoring override for task " + taskName | log("Ignoring override for task " + taskName | ||||
| @@ -812,7 +812,7 @@ public class Project { | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| } | } | ||||
| try { | try { | ||||
| taskClass.getConstructor( null ); | |||||
| taskClass.getConstructor(null); | |||||
| // don't have to check for public, since | // don't have to check for public, since | ||||
| // getConstructor finds public constructors only. | // getConstructor finds public constructors only. | ||||
| } catch (NoSuchMethodException e) { | } catch (NoSuchMethodException e) { | ||||
| @@ -821,7 +821,7 @@ public class Project { | |||||
| log(message, Project.MSG_ERR); | log(message, Project.MSG_ERR); | ||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| } | } | ||||
| if (!Task.class.isAssignableFrom(taskClass) ) { | |||||
| if (!Task.class.isAssignableFrom(taskClass)) { | |||||
| TaskAdapter.checkTaskClass(taskClass, this); | TaskAdapter.checkTaskClass(taskClass, this); | ||||
| } | } | ||||
| } | } | ||||
| @@ -851,7 +851,7 @@ public class Project { | |||||
| * Must not be <code>null</code>. | * Must not be <code>null</code>. | ||||
| */ | */ | ||||
| public void addDataTypeDefinition(String typeName, Class typeClass) { | public void addDataTypeDefinition(String typeName, Class typeClass) { | ||||
| Class old = (Class)dataClassDefinitions.get(typeName); | |||||
| Class old = (Class) dataClassDefinitions.get(typeName); | |||||
| if (null != old) { | if (null != old) { | ||||
| if (old.equals(typeClass)) { | if (old.equals(typeClass)) { | ||||
| log("Ignoring override for datatype " + typeName | log("Ignoring override for datatype " + typeName | ||||
| @@ -978,7 +978,7 @@ public class Project { | |||||
| Object o = c.newInstance(); | Object o = c.newInstance(); | ||||
| Task task = null; | Task task = null; | ||||
| if (o instanceof Task) { | if (o instanceof Task) { | ||||
| task = (Task)o; | |||||
| task = (Task) o; | |||||
| } else { | } else { | ||||
| // "Generic" Bean - use the setter pattern | // "Generic" Bean - use the setter pattern | ||||
| // and an Adapter | // and an Adapter | ||||
| @@ -1085,7 +1085,7 @@ public class Project { | |||||
| o = ctor.newInstance(new Object[] {this}); | o = ctor.newInstance(new Object[] {this}); | ||||
| } | } | ||||
| if (o instanceof ProjectComponent) { | if (o instanceof ProjectComponent) { | ||||
| ((ProjectComponent)o).setProject(this); | |||||
| ((ProjectComponent) o).setProject(this); | |||||
| } | } | ||||
| String msg = " +DataType: " + typeName; | String msg = " +DataType: " + typeName; | ||||
| log (msg, MSG_DEBUG); | log (msg, MSG_DEBUG); | ||||
| @@ -1115,7 +1115,7 @@ public class Project { | |||||
| Throwable error = null; | Throwable error = null; | ||||
| for (int i = 0; i < targetNames.size(); i++) { | for (int i = 0; i < targetNames.size(); i++) { | ||||
| executeTarget((String)targetNames.elementAt(i)); | |||||
| executeTarget((String) targetNames.elementAt(i)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1129,15 +1129,13 @@ public class Project { | |||||
| * or information (<code>false</code>). | * or information (<code>false</code>). | ||||
| */ | */ | ||||
| public void demuxOutput(String line, boolean isError) { | public void demuxOutput(String line, boolean isError) { | ||||
| Task task = (Task)threadTasks.get(Thread.currentThread()); | |||||
| Task task = (Task) threadTasks.get(Thread.currentThread()); | |||||
| if (task == null) { | if (task == null) { | ||||
| fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); | fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| if (isError) { | if (isError) { | ||||
| task.handleErrorOutput(line); | task.handleErrorOutput(line); | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| task.handleOutput(line); | task.handleOutput(line); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1231,7 +1229,7 @@ public class Project { | |||||
| * @see PathTokenizer | * @see PathTokenizer | ||||
| */ | */ | ||||
| public static String translatePath(String toProcess) { | public static String translatePath(String toProcess) { | ||||
| if ( toProcess == null || toProcess.length() == 0 ) { | |||||
| if (toProcess == null || toProcess.length() == 0) { | |||||
| return ""; | return ""; | ||||
| } | } | ||||
| @@ -1510,12 +1508,11 @@ public class Project { | |||||
| tsort(root, targets, state, visiting, ret); | tsort(root, targets, state, visiting, ret); | ||||
| log("Build sequence for target `" + root + "' is " + ret, MSG_VERBOSE); | log("Build sequence for target `" + root + "' is " + ret, MSG_VERBOSE); | ||||
| for (Enumeration en = targets.keys(); en.hasMoreElements();) { | for (Enumeration en = targets.keys(); en.hasMoreElements();) { | ||||
| String curTarget = (String)(en.nextElement()); | |||||
| String curTarget = (String) en.nextElement(); | |||||
| String st = (String) state.get(curTarget); | String st = (String) state.get(curTarget); | ||||
| if (st == null) { | if (st == null) { | ||||
| tsort(curTarget, targets, state, visiting, ret); | tsort(curTarget, targets, state, visiting, ret); | ||||
| } | |||||
| else if (st == VISITING) { | |||||
| } else if (st == VISITING) { | |||||
| throw new RuntimeException("Unexpected node in visiting state: " | throw new RuntimeException("Unexpected node in visiting state: " | ||||
| + curTarget); | + curTarget); | ||||
| } | } | ||||
| @@ -1571,7 +1568,7 @@ public class Project { | |||||
| state.put(root, VISITING); | state.put(root, VISITING); | ||||
| visiting.push(root); | visiting.push(root); | ||||
| Target target = (Target)(targets.get(root)); | |||||
| Target target = (Target) targets.get(root); | |||||
| // Make sure we exist | // Make sure we exist | ||||
| if (target == null) { | if (target == null) { | ||||
| @@ -1580,7 +1577,7 @@ public class Project { | |||||
| sb.append("' does not exist in this project. "); | sb.append("' does not exist in this project. "); | ||||
| visiting.pop(); | visiting.pop(); | ||||
| if (!visiting.empty()) { | if (!visiting.empty()) { | ||||
| String parent = (String)visiting.peek(); | |||||
| String parent = (String) visiting.peek(); | |||||
| sb.append("It is used from target `"); | sb.append("It is used from target `"); | ||||
| sb.append(parent); | sb.append(parent); | ||||
| sb.append("'."); | sb.append("'."); | ||||
| @@ -1591,12 +1588,11 @@ public class Project { | |||||
| for (Enumeration en = target.getDependencies(); en.hasMoreElements();) { | for (Enumeration en = target.getDependencies(); en.hasMoreElements();) { | ||||
| String cur = (String) en.nextElement(); | String cur = (String) en.nextElement(); | ||||
| String m = (String)state.get(cur); | |||||
| String m = (String) state.get(cur); | |||||
| if (m == null) { | if (m == null) { | ||||
| // Not been visited | // Not been visited | ||||
| tsort(cur, targets, state, visiting, ret); | tsort(cur, targets, state, visiting, ret); | ||||
| } | |||||
| else if (m == VISITING) { | |||||
| } else if (m == VISITING) { | |||||
| // Currently visiting this node, so have a cycle | // Currently visiting this node, so have a cycle | ||||
| throw makeCircularException(cur, visiting); | throw makeCircularException(cur, visiting); | ||||
| } | } | ||||
| @@ -1625,7 +1621,7 @@ public class Project { | |||||
| sb.append(end); | sb.append(end); | ||||
| String c; | String c; | ||||
| do { | do { | ||||
| c = (String)stk.pop(); | |||||
| c = (String) stk.pop(); | |||||
| sb.append(" <- "); | sb.append(" <- "); | ||||
| sb.append(c); | sb.append(c); | ||||
| } while (!c.equals(end)); | } while (!c.equals(end)); | ||||
| @@ -1899,7 +1895,7 @@ public class Project { | |||||
| * null if no task is registered. | * null if no task is registered. | ||||
| */ | */ | ||||
| public Task getThreadTask(Thread thread) { | public Task getThreadTask(Thread thread) { | ||||
| return (Task)threadTasks.get(thread); | |||||
| return (Task) threadTasks.get(thread); | |||||
| } | } | ||||
| @@ -105,7 +105,8 @@ public abstract class ProjectComponent { | |||||
| * Logs a mesage with the given priority. | * Logs a mesage with the given priority. | ||||
| * | * | ||||
| * @param msg The message to be logged. Should not be <code>null</code>. | * @param msg The message to be logged. Should not be <code>null</code>. | ||||
| * @param msgLevel the message priority at which this message is to be logged. | |||||
| * @param msgLevel the message priority at which this message is | |||||
| * to be logged. | |||||
| */ | */ | ||||
| public void log(String msg, int msgLevel) { | public void log(String msg, int msgLevel) { | ||||
| if (project != null) { | if (project != null) { | ||||
| @@ -198,7 +198,7 @@ public class ProjectHelper { | |||||
| if (helperClassName != null && | if (helperClassName != null && | ||||
| !"".equals(helperClassName)) { | !"".equals(helperClassName)) { | ||||
| helper = newHelper( helperClassName ); | |||||
| helper = newHelper(helperClassName); | |||||
| } | } | ||||
| } | } | ||||
| } catch (Exception ex) { | } catch (Exception ex) { | ||||
| @@ -281,7 +281,7 @@ public class ProjectHelper { | |||||
| public static void configure(Object target, AttributeList attrs, | public static void configure(Object target, AttributeList attrs, | ||||
| Project project) throws BuildException { | Project project) throws BuildException { | ||||
| if (target instanceof TaskAdapter) { | if (target instanceof TaskAdapter) { | ||||
| target = ((TaskAdapter)target).getProxy(); | |||||
| target = ((TaskAdapter) target).getProxy(); | |||||
| } | } | ||||
| IntrospectionHelper ih = | IntrospectionHelper ih = | ||||
| @@ -292,7 +292,7 @@ public class ProjectHelper { | |||||
| for (int i = 0; i < attrs.getLength(); i++) { | for (int i = 0; i < attrs.getLength(); i++) { | ||||
| // reflect these into the target | // reflect these into the target | ||||
| String value = replaceProperties(project, attrs.getValue(i), | String value = replaceProperties(project, attrs.getValue(i), | ||||
| project.getProperties() ); | |||||
| project.getProperties()); | |||||
| try { | try { | ||||
| ih.setAttribute(project, target, | ih.setAttribute(project, target, | ||||
| attrs.getName(i).toLowerCase(Locale.US), value); | attrs.getName(i).toLowerCase(Locale.US), value); | ||||
| @@ -341,7 +341,7 @@ public class ProjectHelper { | |||||
| public static void addText(Project project, Object target, String text) | public static void addText(Project project, Object target, String text) | ||||
| throws BuildException { | throws BuildException { | ||||
| if (text == null ) { | |||||
| if (text == null) { | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -368,7 +368,8 @@ public class ProjectHelper { | |||||
| */ | */ | ||||
| public static void storeChild(Project project, Object parent, | public static void storeChild(Project project, Object parent, | ||||
| Object child, String tag) { | Object child, String tag) { | ||||
| IntrospectionHelper ih = IntrospectionHelper.getHelper(parent.getClass()); | |||||
| IntrospectionHelper ih | |||||
| = IntrospectionHelper.getHelper(parent.getClass()); | |||||
| ih.storeElement(project, parent, child, tag); | ih.storeElement(project, parent, child, tag); | ||||
| } | } | ||||
| @@ -427,9 +428,9 @@ public class ProjectHelper { | |||||
| Enumeration i = fragments.elements(); | Enumeration i = fragments.elements(); | ||||
| Enumeration j = propertyRefs.elements(); | Enumeration j = propertyRefs.elements(); | ||||
| while (i.hasMoreElements()) { | while (i.hasMoreElements()) { | ||||
| String fragment = (String)i.nextElement(); | |||||
| String fragment = (String) i.nextElement(); | |||||
| if (fragment == null) { | if (fragment == null) { | ||||
| String propertyName = (String)j.nextElement(); | |||||
| String propertyName = (String) j.nextElement(); | |||||
| if (!keys.containsKey(propertyName)) { | if (!keys.containsKey(propertyName)) { | ||||
| project.log("Property ${" + propertyName | project.log("Property ${" + propertyName | ||||
| + "} has not been set", Project.MSG_VERBOSE); | + "} has not been set", Project.MSG_VERBOSE); | ||||
| @@ -476,12 +477,11 @@ public class ProjectHelper { | |||||
| } | } | ||||
| //if we are at the end of the string, we tack on a $ | //if we are at the end of the string, we tack on a $ | ||||
| //then move past it | //then move past it | ||||
| if( pos == (value.length() - 1)) { | |||||
| if (pos == (value.length() - 1)) { | |||||
| fragments.addElement("$"); | fragments.addElement("$"); | ||||
| prev = pos + 1; | prev = pos + 1; | ||||
| } | |||||
| //peek ahead to see if the next char is a property or not | |||||
| else if (value.charAt(pos + 1) != '{' ) { | |||||
| } else if (value.charAt(pos + 1) != '{') { | |||||
| //peek ahead to see if the next char is a property or not | |||||
| //not a property: insert the char as a literal | //not a property: insert the char as a literal | ||||
| fragments.addElement(value.substring(pos + 1, pos + 2)); | fragments.addElement(value.substring(pos + 1, pos + 2)); | ||||
| prev = pos + 2; | prev = pos + 2; | ||||
| @@ -490,7 +490,7 @@ public class ProjectHelper { | |||||
| int endName = value.indexOf('}', pos); | int endName = value.indexOf('}', pos); | ||||
| if (endName < 0) { | if (endName < 0) { | ||||
| throw new BuildException("Syntax error in property: " | throw new BuildException("Syntax error in property: " | ||||
| + value ); | |||||
| + value); | |||||
| } | } | ||||
| String propertyName = value.substring(pos + 2, endName); | String propertyName = value.substring(pos + 2, endName); | ||||
| fragments.addElement(null); | fragments.addElement(null); | ||||
| @@ -208,7 +208,8 @@ public class RuntimeConfigurable { | |||||
| } | } | ||||
| Enumeration enum = children.elements(); | Enumeration enum = children.elements(); | ||||
| while (enum.hasMoreElements()) { | while (enum.hasMoreElements()) { | ||||
| RuntimeConfigurable child = (RuntimeConfigurable) enum.nextElement(); | |||||
| RuntimeConfigurable child | |||||
| = (RuntimeConfigurable) enum.nextElement(); | |||||
| if (child.wrappedObject instanceof Task) { | if (child.wrappedObject instanceof Task) { | ||||
| Task childTask = (Task) child.wrappedObject; | Task childTask = (Task) child.wrappedObject; | ||||
| childTask.setRuntimeConfigurableWrapper(child); | childTask.setRuntimeConfigurableWrapper(child); | ||||
| @@ -216,7 +217,8 @@ public class RuntimeConfigurable { | |||||
| } else { | } else { | ||||
| child.maybeConfigure(p); | child.maybeConfigure(p); | ||||
| } | } | ||||
| ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject, child.getElementTag().toLowerCase(Locale.US)); | |||||
| ProjectHelper.storeChild(p, wrappedObject, child.wrappedObject, | |||||
| child.getElementTag().toLowerCase(Locale.US)); | |||||
| } | } | ||||
| if (id != null) { | if (id != null) { | ||||
| @@ -120,9 +120,9 @@ public class Target implements TaskContainer { | |||||
| // Make sure the dependency is not empty string | // Make sure the dependency is not empty string | ||||
| if (token.equals("") || token.equals(",")) { | if (token.equals("") || token.equals(",")) { | ||||
| throw new BuildException( "Syntax Error: Depend attribute " + | |||||
| "for target \"" + getName() + | |||||
| "\" has an empty string for dependency." ); | |||||
| throw new BuildException("Syntax Error: Depend " | |||||
| + "attribute for target \"" + getName() | |||||
| + "\" has an empty string for dependency."); | |||||
| } | } | ||||
| addDependency(token); | addDependency(token); | ||||
| @@ -132,9 +132,9 @@ public class Target implements TaskContainer { | |||||
| if (tok.hasMoreTokens()) { | if (tok.hasMoreTokens()) { | ||||
| token = tok.nextToken(); | token = tok.nextToken(); | ||||
| if (!tok.hasMoreTokens() || !token.equals(",")) { | if (!tok.hasMoreTokens() || !token.equals(",")) { | ||||
| throw new BuildException( "Syntax Error: Depend attribute " + | |||||
| "for target \"" + getName() + | |||||
| "\" ends with a , character" ); | |||||
| throw new BuildException("Syntax Error: Depend " | |||||
| + "attribute for target \"" + getName() | |||||
| + "\" ends with a , character"); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -313,11 +313,11 @@ public class Target implements TaskContainer { | |||||
| } | } | ||||
| } | } | ||||
| } else if (!testIfCondition()) { | } else if (!testIfCondition()) { | ||||
| project.log(this, "Skipped because property '" + this.ifCondition + "' not set.", | |||||
| Project.MSG_VERBOSE); | |||||
| project.log(this, "Skipped because property '" + this.ifCondition | |||||
| + "' not set.", Project.MSG_VERBOSE); | |||||
| } else { | } else { | ||||
| project.log(this, "Skipped because property '" + this.unlessCondition + "' set.", | |||||
| Project.MSG_VERBOSE); | |||||
| project.log(this, "Skipped because property '" | |||||
| + this.unlessCondition + "' set.", Project.MSG_VERBOSE); | |||||
| } | } | ||||
| } | } | ||||
| @@ -333,8 +333,7 @@ public class Target implements TaskContainer { | |||||
| project.fireTargetStarted(this); | project.fireTargetStarted(this); | ||||
| execute(); | execute(); | ||||
| project.fireTargetFinished(this, null); | project.fireTargetFinished(this, null); | ||||
| } | |||||
| catch(RuntimeException exc) { | |||||
| } catch (RuntimeException exc) { | |||||
| project.fireTargetFinished(this, exc); | project.fireTargetFinished(this, exc); | ||||
| throw exc; | throw exc; | ||||
| } | } | ||||
| @@ -151,7 +151,7 @@ public abstract class Task extends ProjectComponent { | |||||
| * available. | * available. | ||||
| * | * | ||||
| */ | */ | ||||
| public void setDescription( String desc ) { | |||||
| public void setDescription(String desc) { | |||||
| description = desc; | description = desc; | ||||
| } | } | ||||
| @@ -312,8 +312,7 @@ public abstract class Task extends ProjectComponent { | |||||
| maybeConfigure(); | maybeConfigure(); | ||||
| execute(); | execute(); | ||||
| project.fireTaskFinished(this, null); | project.fireTaskFinished(this, null); | ||||
| } | |||||
| catch (RuntimeException exc) { | |||||
| } catch (RuntimeException exc) { | |||||
| if (exc instanceof BuildException) { | if (exc instanceof BuildException) { | ||||
| BuildException be = (BuildException) exc; | BuildException be = (BuildException) exc; | ||||
| if (be.getLocation() == Location.UNKNOWN_LOCATION) { | if (be.getLocation() == Location.UNKNOWN_LOCATION) { | ||||
| @@ -9,7 +9,7 @@ | |||||
| * are met: | * are met: | ||||
| * | * | ||||
| * 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | * | ||||
| * 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
| * notice, this list of conditions and the following disclaimer in | * notice, this list of conditions and the following disclaimer in | ||||
| @@ -17,7 +17,7 @@ | |||||
| * distribution. | * distribution. | ||||
| * | * | ||||
| * 3. The end-user documentation included with the redistribution, if | * 3. The end-user documentation included with the redistribution, if | ||||
| * any, must include the following acknowlegement: | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | * "This product includes software developed by the | ||||
| * Apache Software Foundation (http://www.apache.org/)." | * Apache Software Foundation (http://www.apache.org/)." | ||||
| * Alternately, this acknowlegement may appear in the software itself, | * Alternately, this acknowlegement may appear in the software itself, | ||||
| @@ -66,7 +66,7 @@ import java.lang.reflect.Method; | |||||
| public class TaskAdapter extends Task { | public class TaskAdapter extends Task { | ||||
| /** Object to act as a proxy for. */ | /** Object to act as a proxy for. */ | ||||
| Object proxy; | |||||
| private Object proxy; | |||||
| /** | /** | ||||
| * Checks whether or not a class is suitable to be adapted by TaskAdapter. | * Checks whether or not a class is suitable to be adapted by TaskAdapter. | ||||
| @@ -86,20 +86,23 @@ public class TaskAdapter extends Task { | |||||
| * | * | ||||
| * @see Project#checkTaskClass(Class) | * @see Project#checkTaskClass(Class) | ||||
| */ | */ | ||||
| public static void checkTaskClass(final Class taskClass, final Project project) { | |||||
| public static void checkTaskClass(final Class taskClass, | |||||
| final Project project) { | |||||
| // don't have to check for interface, since then | // don't have to check for interface, since then | ||||
| // taskClass would be abstract too. | // taskClass would be abstract too. | ||||
| try { | try { | ||||
| final Method executeM = taskClass.getMethod( "execute", null ); | |||||
| final Method executeM = taskClass.getMethod("execute", null); | |||||
| // don't have to check for public, since | // don't have to check for public, since | ||||
| // getMethod finds public method only. | // getMethod finds public method only. | ||||
| // don't have to check for abstract, since then | // don't have to check for abstract, since then | ||||
| // taskClass would be abstract too. | // taskClass would be abstract too. | ||||
| if(!Void.TYPE.equals(executeM.getReturnType())) { | |||||
| final String message = "return type of execute() should be void but was \""+executeM.getReturnType()+"\" in " + taskClass; | |||||
| if (!Void.TYPE.equals(executeM.getReturnType())) { | |||||
| final String message = "return type of execute() should be " | |||||
| + "void but was \"" + executeM.getReturnType() + "\" in " | |||||
| + taskClass; | |||||
| project.log(message, Project.MSG_WARN); | project.log(message, Project.MSG_WARN); | ||||
| } | } | ||||
| } catch(NoSuchMethodException e) { | |||||
| } catch (NoSuchMethodException e) { | |||||
| final String message = "No public execute() in " + taskClass; | final String message = "No public execute() in " + taskClass; | ||||
| project.log(message, Project.MSG_ERR); | project.log(message, Project.MSG_ERR); | ||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| @@ -117,27 +120,29 @@ public class TaskAdapter extends Task { | |||||
| try { | try { | ||||
| Class c = proxy.getClass(); | Class c = proxy.getClass(); | ||||
| setProjectM = | setProjectM = | ||||
| c.getMethod( "setProject", new Class[] {Project.class}); | |||||
| if(setProjectM != null) { | |||||
| c.getMethod("setProject", new Class[] {Project.class}); | |||||
| if (setProjectM != null) { | |||||
| setProjectM.invoke(proxy, new Object[] {project}); | setProjectM.invoke(proxy, new Object[] {project}); | ||||
| } | } | ||||
| } catch (NoSuchMethodException e) { | } catch (NoSuchMethodException e) { | ||||
| // ignore this if the class being used as a task does not have | // ignore this if the class being used as a task does not have | ||||
| // a set project method. | // a set project method. | ||||
| } catch( Exception ex ) { | |||||
| } catch (Exception ex) { | |||||
| log("Error setting project in " + proxy.getClass(), | log("Error setting project in " + proxy.getClass(), | ||||
| Project.MSG_ERR); | Project.MSG_ERR); | ||||
| throw new BuildException( ex ); | |||||
| throw new BuildException(ex); | |||||
| } | } | ||||
| Method executeM=null; | |||||
| Method executeM = null; | |||||
| try { | try { | ||||
| Class c=proxy.getClass(); | |||||
| executeM=c.getMethod( "execute", new Class[0] ); | |||||
| if( executeM == null ) { | |||||
| log("No public execute() in " + proxy.getClass(), Project.MSG_ERR); | |||||
| throw new BuildException("No public execute() in " + proxy.getClass()); | |||||
| Class c = proxy.getClass(); | |||||
| executeM = c.getMethod("execute", new Class[0]); | |||||
| if (executeM == null) { | |||||
| log("No public execute() in " + proxy.getClass(), | |||||
| Project.MSG_ERR); | |||||
| throw new BuildException("No public execute() in " | |||||
| + proxy.getClass()); | |||||
| } | } | ||||
| executeM.invoke(proxy, null); | executeM.invoke(proxy, null); | ||||
| return; | return; | ||||
| @@ -149,9 +154,9 @@ public class TaskAdapter extends Task { | |||||
| } else { | } else { | ||||
| throw new BuildException(t); | throw new BuildException(t); | ||||
| } | } | ||||
| } catch( Exception ex ) { | |||||
| } catch (Exception ex) { | |||||
| log("Error in " + proxy.getClass(), Project.MSG_ERR); | log("Error in " + proxy.getClass(), Project.MSG_ERR); | ||||
| throw new BuildException( ex ); | |||||
| throw new BuildException(ex); | |||||
| } | } | ||||
| } | } | ||||
| @@ -136,7 +136,7 @@ public class UnknownElement extends Task { | |||||
| */ | */ | ||||
| protected void handleOutput(String line) { | protected void handleOutput(String line) { | ||||
| if (realThing instanceof Task) { | if (realThing instanceof Task) { | ||||
| ((Task)realThing).handleOutput(line); | |||||
| ((Task) realThing).handleOutput(line); | |||||
| } else { | } else { | ||||
| super.handleOutput(line); | super.handleOutput(line); | ||||
| } | } | ||||
| @@ -149,7 +149,7 @@ public class UnknownElement extends Task { | |||||
| */ | */ | ||||
| protected void handleErrorOutput(String line) { | protected void handleErrorOutput(String line) { | ||||
| if (realThing instanceof Task) { | if (realThing instanceof Task) { | ||||
| ((Task)realThing).handleErrorOutput(line); | |||||
| ((Task) realThing).handleErrorOutput(line); | |||||
| } else { | } else { | ||||
| super.handleErrorOutput(line); | super.handleErrorOutput(line); | ||||
| } | } | ||||
| @@ -87,7 +87,7 @@ import org.apache.tools.ant.util.StringUtils; | |||||
| public class XmlLogger implements BuildListener { | public class XmlLogger implements BuildListener { | ||||
| /** DocumentBuilder to use when creating the document to start with. */ | /** DocumentBuilder to use when creating the document to start with. */ | ||||
| private final static DocumentBuilder builder = getDocumentBuilder(); | |||||
| private static final DocumentBuilder builder = getDocumentBuilder(); | |||||
| /** | /** | ||||
| * Returns a default DocumentBuilder instance or throws an | * Returns a default DocumentBuilder instance or throws an | ||||
| @@ -98,32 +98,31 @@ public class XmlLogger implements BuildListener { | |||||
| private static DocumentBuilder getDocumentBuilder() { | private static DocumentBuilder getDocumentBuilder() { | ||||
| try { | try { | ||||
| return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | ||||
| } | |||||
| catch(Exception exc) { | |||||
| } catch (Exception exc) { | |||||
| throw new ExceptionInInitializerError(exc); | throw new ExceptionInInitializerError(exc); | ||||
| } | } | ||||
| } | } | ||||
| /** XML element name for a build. */ | /** XML element name for a build. */ | ||||
| private final static String BUILD_TAG = "build"; | |||||
| private static final String BUILD_TAG = "build"; | |||||
| /** XML element name for a target. */ | /** XML element name for a target. */ | ||||
| private final static String TARGET_TAG = "target"; | |||||
| private static final String TARGET_TAG = "target"; | |||||
| /** XML element name for a task. */ | /** XML element name for a task. */ | ||||
| private final static String TASK_TAG = "task"; | |||||
| private static final String TASK_TAG = "task"; | |||||
| /** XML element name for a message. */ | /** XML element name for a message. */ | ||||
| private final static String MESSAGE_TAG = "message"; | |||||
| private static final String MESSAGE_TAG = "message"; | |||||
| /** XML attribute name for a name. */ | /** XML attribute name for a name. */ | ||||
| private final static String NAME_ATTR = "name"; | |||||
| private static final String NAME_ATTR = "name"; | |||||
| /** XML attribute name for a time. */ | /** XML attribute name for a time. */ | ||||
| private final static String TIME_ATTR = "time"; | |||||
| private static final String TIME_ATTR = "time"; | |||||
| /** XML attribute name for a message priority. */ | /** XML attribute name for a message priority. */ | ||||
| private final static String PRIORITY_ATTR = "priority"; | |||||
| private static final String PRIORITY_ATTR = "priority"; | |||||
| /** XML attribute name for a file location. */ | /** XML attribute name for a file location. */ | ||||
| private final static String LOCATION_ATTR = "location"; | |||||
| private static final String LOCATION_ATTR = "location"; | |||||
| /** XML attribute name for an error description. */ | /** XML attribute name for an error description. */ | ||||
| private final static String ERROR_ATTR = "error"; | |||||
| private static final String ERROR_ATTR = "error"; | |||||
| /** XML element name for a stack trace. */ | /** XML element name for a stack trace. */ | ||||
| private final static String STACKTRACE_TAG = "stacktrace"; | |||||
| private static final String STACKTRACE_TAG = "stacktrace"; | |||||
| /** The complete log document for this build. */ | /** The complete log document for this build. */ | ||||
| private Document doc = builder.newDocument(); | private Document doc = builder.newDocument(); | ||||
| @@ -147,9 +146,9 @@ public class XmlLogger implements BuildListener { | |||||
| * Start time in milliseconds | * Start time in milliseconds | ||||
| * (as returned by <code>System.currentTimeMillis()</code>). | * (as returned by <code>System.currentTimeMillis()</code>). | ||||
| */ | */ | ||||
| long startTime; | |||||
| private long startTime; | |||||
| /** Element created at the start time. */ | /** Element created at the start time. */ | ||||
| Element element; | |||||
| private Element element; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -179,14 +178,16 @@ public class XmlLogger implements BuildListener { | |||||
| */ | */ | ||||
| public void buildFinished(BuildEvent event) { | public void buildFinished(BuildEvent event) { | ||||
| long totalTime = System.currentTimeMillis() - buildElement.startTime; | long totalTime = System.currentTimeMillis() - buildElement.startTime; | ||||
| buildElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); | |||||
| buildElement.element.setAttribute(TIME_ATTR, | |||||
| DefaultLogger.formatTime(totalTime)); | |||||
| if (event.getException() != null) { | if (event.getException() != null) { | ||||
| buildElement.element.setAttribute(ERROR_ATTR, event.getException().toString()); | |||||
| buildElement.element.setAttribute(ERROR_ATTR, | |||||
| event.getException().toString()); | |||||
| // print the stacktrace in the build file it is always useful... | // print the stacktrace in the build file it is always useful... | ||||
| // better have too much info than not enough. | // better have too much info than not enough. | ||||
| Throwable t = event.getException(); | Throwable t = event.getException(); | ||||
| Text errText = doc.createCDATASection(StringUtils.getStackTrace(t)); | |||||
| Text errText = doc.createCDATASection(StringUtils.getStackTrace(t)); | |||||
| Element stacktrace = doc.createElement(STACKTRACE_TAG); | Element stacktrace = doc.createElement(STACKTRACE_TAG); | ||||
| stacktrace.appendChild(errText); | stacktrace.appendChild(errText); | ||||
| buildElement.element.appendChild(stacktrace); | buildElement.element.appendChild(stacktrace); | ||||
| @@ -196,9 +197,10 @@ public class XmlLogger implements BuildListener { | |||||
| if (outFilename == null) { | if (outFilename == null) { | ||||
| outFilename = "log.xml"; | outFilename = "log.xml"; | ||||
| } | } | ||||
| String xslUri=event.getProject().getProperty("ant.XmlLogger.stylesheet.uri"); | |||||
| if(xslUri==null) { | |||||
| xslUri="log.xsl"; | |||||
| String xslUri | |||||
| = event.getProject().getProperty("ant.XmlLogger.stylesheet.uri"); | |||||
| if (xslUri == null) { | |||||
| xslUri = "log.xsl"; | |||||
| } | } | ||||
| Writer out = null; | Writer out = null; | ||||
| try { | try { | ||||
| @@ -207,12 +209,13 @@ public class XmlLogger implements BuildListener { | |||||
| FileOutputStream fos = new FileOutputStream(outFilename); | FileOutputStream fos = new FileOutputStream(outFilename); | ||||
| out = new OutputStreamWriter(fos, "UTF8"); | out = new OutputStreamWriter(fos, "UTF8"); | ||||
| out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); | out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); | ||||
| if(xslUri.length()>0) { | |||||
| out.write("<?xml-stylesheet type=\"text/xsl\" href=\""+xslUri+"\"?>\n\n"); | |||||
| if (xslUri.length() > 0) { | |||||
| out.write("<?xml-stylesheet type=\"text/xsl\" href=\"" | |||||
| + xslUri + "\"?>\n\n"); | |||||
| } | } | ||||
| (new DOMElementWriter()).write(buildElement.element, out, 0, "\t"); | (new DOMElementWriter()).write(buildElement.element, out, 0, "\t"); | ||||
| out.flush(); | out.flush(); | ||||
| } catch(IOException exc) { | |||||
| } catch (IOException exc) { | |||||
| throw new BuildException("Unable to write log file", exc); | throw new BuildException("Unable to write log file", exc); | ||||
| } finally { | } finally { | ||||
| if (out != null){ | if (out != null){ | ||||
| @@ -229,7 +232,7 @@ public class XmlLogger implements BuildListener { | |||||
| * @return the stack of timed elements for the current thread | * @return the stack of timed elements for the current thread | ||||
| */ | */ | ||||
| private Stack getStack() { | private Stack getStack() { | ||||
| Stack threadStack = (Stack)threadStacks.get(Thread.currentThread()); | |||||
| Stack threadStack = (Stack) threadStacks.get(Thread.currentThread()); | |||||
| if (threadStack == null) { | if (threadStack == null) { | ||||
| threadStack = new Stack(); | threadStack = new Stack(); | ||||
| threadStacks.put(Thread.currentThread(), threadStack); | threadStacks.put(Thread.currentThread(), threadStack); | ||||
| @@ -264,27 +267,29 @@ public class XmlLogger implements BuildListener { | |||||
| */ | */ | ||||
| public void targetFinished(BuildEvent event) { | public void targetFinished(BuildEvent event) { | ||||
| Target target = event.getTarget(); | Target target = event.getTarget(); | ||||
| TimedElement targetElement = (TimedElement)targets.get(target); | |||||
| TimedElement targetElement = (TimedElement) targets.get(target); | |||||
| if (targetElement != null) { | if (targetElement != null) { | ||||
| long totalTime = System.currentTimeMillis() - targetElement.startTime; | |||||
| targetElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); | |||||
| long totalTime | |||||
| = System.currentTimeMillis() - targetElement.startTime; | |||||
| targetElement.element.setAttribute(TIME_ATTR, | |||||
| DefaultLogger.formatTime(totalTime)); | |||||
| TimedElement parentElement = null; | TimedElement parentElement = null; | ||||
| Stack threadStack = getStack(); | Stack threadStack = getStack(); | ||||
| if (!threadStack.empty()) { | if (!threadStack.empty()) { | ||||
| TimedElement poppedStack = (TimedElement)threadStack.pop(); | |||||
| TimedElement poppedStack = (TimedElement) threadStack.pop(); | |||||
| if (poppedStack != targetElement) { | if (poppedStack != targetElement) { | ||||
| throw new RuntimeException("Mismatch - popped element = " + poppedStack.element + | |||||
| " finished target element = " + targetElement.element); | |||||
| throw new RuntimeException("Mismatch - popped element = " | |||||
| + poppedStack.element + " finished target element = " | |||||
| + targetElement.element); | |||||
| } | } | ||||
| if (!threadStack.empty()) { | if (!threadStack.empty()) { | ||||
| parentElement = (TimedElement)threadStack.peek(); | |||||
| parentElement = (TimedElement) threadStack.peek(); | |||||
| } | } | ||||
| } | } | ||||
| if (parentElement == null) { | if (parentElement == null) { | ||||
| buildElement.element.appendChild(targetElement.element); | buildElement.element.appendChild(targetElement.element); | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| parentElement.element.appendChild(targetElement.element); | parentElement.element.appendChild(targetElement.element); | ||||
| } | } | ||||
| } | } | ||||
| @@ -306,7 +311,8 @@ public class XmlLogger implements BuildListener { | |||||
| String name = event.getTask().getTaskName(); | String name = event.getTask().getTaskName(); | ||||
| taskElement.element.setAttribute(NAME_ATTR, name); | taskElement.element.setAttribute(NAME_ATTR, name); | ||||
| taskElement.element.setAttribute(LOCATION_ATTR, event.getTask().getLocation().toString()); | |||||
| taskElement.element.setAttribute(LOCATION_ATTR, | |||||
| event.getTask().getLocation().toString()); | |||||
| tasks.put(task, taskElement); | tasks.put(task, taskElement); | ||||
| getStack().push(taskElement); | getStack().push(taskElement); | ||||
| } | } | ||||
| @@ -320,27 +326,28 @@ public class XmlLogger implements BuildListener { | |||||
| */ | */ | ||||
| public void taskFinished(BuildEvent event) { | public void taskFinished(BuildEvent event) { | ||||
| Task task = event.getTask(); | Task task = event.getTask(); | ||||
| TimedElement taskElement = (TimedElement)tasks.get(task); | |||||
| TimedElement taskElement = (TimedElement) tasks.get(task); | |||||
| if (taskElement != null) { | if (taskElement != null) { | ||||
| long totalTime = System.currentTimeMillis() - taskElement.startTime; | long totalTime = System.currentTimeMillis() - taskElement.startTime; | ||||
| taskElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); | |||||
| taskElement.element.setAttribute(TIME_ATTR, | |||||
| DefaultLogger.formatTime(totalTime)); | |||||
| Target target = task.getOwningTarget(); | Target target = task.getOwningTarget(); | ||||
| TimedElement targetElement = null; | TimedElement targetElement = null; | ||||
| if (target != null) { | if (target != null) { | ||||
| targetElement = (TimedElement)targets.get(target); | |||||
| targetElement = (TimedElement) targets.get(target); | |||||
| } | } | ||||
| if (targetElement == null) { | if (targetElement == null) { | ||||
| buildElement.element.appendChild(taskElement.element); | buildElement.element.appendChild(taskElement.element); | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| targetElement.element.appendChild(taskElement.element); | targetElement.element.appendChild(taskElement.element); | ||||
| } | } | ||||
| Stack threadStack = getStack(); | Stack threadStack = getStack(); | ||||
| if (!threadStack.empty()) { | if (!threadStack.empty()) { | ||||
| TimedElement poppedStack = (TimedElement)threadStack.pop(); | |||||
| TimedElement poppedStack = (TimedElement) threadStack.pop(); | |||||
| if (poppedStack != taskElement) { | if (poppedStack != taskElement) { | ||||
| throw new RuntimeException("Mismatch - popped element = " + poppedStack.element + | |||||
| " finished task element = " + taskElement.element); | |||||
| throw new RuntimeException("Mismatch - popped element = " | |||||
| + poppedStack.element + " finished task element = " | |||||
| + taskElement.element); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -374,25 +381,25 @@ public class XmlLogger implements BuildListener { | |||||
| Task task = event.getTask(); | Task task = event.getTask(); | ||||
| Target target = event.getTarget(); | Target target = event.getTarget(); | ||||
| if (task != null) { | if (task != null) { | ||||
| parentElement = (TimedElement)tasks.get(task); | |||||
| parentElement = (TimedElement) tasks.get(task); | |||||
| } | } | ||||
| if (parentElement == null && target != null) { | if (parentElement == null && target != null) { | ||||
| parentElement = (TimedElement)targets.get(target); | |||||
| parentElement = (TimedElement) targets.get(target); | |||||
| } | } | ||||
| if (parentElement == null) { | if (parentElement == null) { | ||||
| Stack threadStack = (Stack)threadStacks.get(Thread.currentThread()); | |||||
| Stack threadStack | |||||
| = (Stack) threadStacks.get(Thread.currentThread()); | |||||
| if (threadStack != null) { | if (threadStack != null) { | ||||
| if (!threadStack.empty()) { | if (!threadStack.empty()) { | ||||
| parentElement = (TimedElement)threadStack.peek(); | |||||
| parentElement = (TimedElement) threadStack.peek(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (parentElement != null) { | if (parentElement != null) { | ||||
| parentElement.element.appendChild(messageElement); | parentElement.element.appendChild(messageElement); | ||||
| } | |||||
| else { | |||||
| } else { | |||||
| buildElement.element.appendChild(messageElement); | buildElement.element.appendChild(messageElement); | ||||
| } | } | ||||
| } | } | ||||