git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@615452 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -86,7 +86,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
| private static final String FIXCRLF_ERROR = "<fixcrlf> error: "; | |||
| /** error string for using srcdir and file */ | |||
| public static final String ERROR_FILE_AND_SRCDIR | |||
| =FIXCRLF_ERROR+"srcdir and file are mutually exclusive"; | |||
| = FIXCRLF_ERROR + "srcdir and file are mutually exclusive"; | |||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | |||
| @@ -314,20 +314,27 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
| srcDir = file.getParentFile(); | |||
| } | |||
| if (srcDir == null) { | |||
| throw new BuildException(FIXCRLF_ERROR +"srcdir attribute must be set!"); | |||
| throw new BuildException( | |||
| FIXCRLF_ERROR + "srcdir attribute must be set!"); | |||
| } | |||
| if (!srcDir.exists()) { | |||
| throw new BuildException(FIXCRLF_ERROR +"srcdir does not exist: '"+srcDir+"'"); | |||
| throw new BuildException( | |||
| FIXCRLF_ERROR + "srcdir does not exist: '" + srcDir + "'"); | |||
| } | |||
| if (!srcDir.isDirectory()) { | |||
| throw new BuildException(FIXCRLF_ERROR +"srcdir is not a directory: '"+srcDir+"'"); | |||
| throw new BuildException( | |||
| FIXCRLF_ERROR + "srcdir is not a directory: '" + srcDir + "'"); | |||
| } | |||
| if (destDir != null) { | |||
| if (!destDir.exists()) { | |||
| throw new BuildException(FIXCRLF_ERROR +"destdir does not exist: '" + destDir + "'"); | |||
| throw new BuildException( | |||
| FIXCRLF_ERROR + "destdir does not exist: '" | |||
| + destDir + "'"); | |||
| } | |||
| if (!destDir.isDirectory()) { | |||
| throw new BuildException(FIXCRLF_ERROR +"destdir is not a directory: '" + destDir + "'"); | |||
| throw new BuildException( | |||
| FIXCRLF_ERROR + "destdir is not a directory: '" | |||
| + destDir + "'"); | |||
| } | |||
| } | |||
| } | |||
| @@ -165,7 +165,9 @@ public class Funtest extends Task { | |||
| /** {@value} */ | |||
| public static final String SKIPPING_TESTS | |||
| = "Condition failed -skipping tests"; | |||
| /** Application exception */ | |||
| public static final String APPLICATION_EXCEPTION = "Application Exception"; | |||
| /** Teardown exception */ | |||
| public static final String TEARDOWN_EXCEPTION = "Teardown Exception"; | |||
| /** | |||
| @@ -533,7 +535,7 @@ public class Funtest extends Task { | |||
| * @param thrown what was thrown | |||
| */ | |||
| protected void ignoringThrowable(String type, Throwable thrown) { | |||
| log(type + ": "+ thrown.toString(), | |||
| log(type + ": " + thrown.toString(), | |||
| thrown, | |||
| Project.MSG_WARN); | |||
| } | |||
| @@ -502,7 +502,7 @@ public class Symlink extends DispatchTask { | |||
| try { | |||
| Execute.runCommand(this, cmd); | |||
| } catch (BuildException failedToExecute) { | |||
| if(failonerror) { | |||
| if (failonerror) { | |||
| throw failedToExecute; | |||
| } else { | |||
| //log at the info level, and keep going. | |||
| @@ -1,9 +1,10 @@ | |||
| /* | |||
| * Copyright 2007 The Apache Software Foundation | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * Licensed to the Apache Software Foundation (ASF) under one or more | |||
| * contributor license agreements. See the NOTICE file distributed with | |||
| * this work for additional information regarding copyright ownership. | |||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | |||
| * (the "License"); you may not use this file except in compliance with | |||
| * the License. You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| @@ -33,8 +34,8 @@ import java.io.IOException; | |||
| */ | |||
| public abstract class AbstractClasspathResource extends Resource { | |||
| protected Path classpath; | |||
| protected Reference loader; | |||
| private Path classpath; | |||
| private Reference loader; | |||
| /** | |||
| * Set the classpath to use when looking up a resource. | |||
| @@ -80,6 +81,14 @@ public abstract class AbstractClasspathResource extends Resource { | |||
| ? ((JavaResource) getCheckedRef()).getClasspath() : classpath; | |||
| } | |||
| /** | |||
| * Get the loader. | |||
| * @return the loader. | |||
| */ | |||
| public Reference getLoader() { | |||
| return loader; | |||
| } | |||
| /** | |||
| * Use the reference to locate the loader. If the loader is not | |||
| * found, taskdef will use the specified classpath and register it | |||
| @@ -1,9 +1,10 @@ | |||
| /* | |||
| * Copyright 2008 The Apache Software Foundation | |||
| * | |||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||
| * you may not use this file except in compliance with the License. | |||
| * You may obtain a copy of the License at | |||
| * Licensed to the Apache Software Foundation (ASF) under one or more | |||
| * contributor license agreements. See the NOTICE file distributed with | |||
| * this work for additional information regarding copyright ownership. | |||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | |||
| * (the "License"); you may not use this file except in compliance with | |||
| * the License. You may obtain a copy of the License at | |||
| * | |||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||
| * | |||
| @@ -47,14 +48,18 @@ public class JavaConstantResource extends AbstractClasspathResource { | |||
| String classname = constant.substring(0, index); | |||
| String fieldname = constant.substring(index + 1, constant.length()); | |||
| try { | |||
| clazz = cl!=null?Class.forName(classname,true,cl):Class.forName(classname); | |||
| clazz = | |||
| cl != null | |||
| ? Class.forName(classname, true, cl) | |||
| : Class.forName(classname); | |||
| Field field = clazz.getField(fieldname); | |||
| String value=field.get(null).toString(); | |||
| String value = field.get(null).toString(); | |||
| return new ByteArrayInputStream(value.getBytes("UTF-8")); | |||
| } catch (ClassNotFoundException e) { | |||
| throw new IOException("Class not found:"+ classname); | |||
| throw new IOException("Class not found:" + classname); | |||
| } catch (NoSuchFieldException e) { | |||
| throw new IOException("Field not found:" + fieldname+ " in "+classname); | |||
| throw new IOException( | |||
| "Field not found:" + fieldname + " in " + classname); | |||
| } catch (IllegalAccessException e) { | |||
| throw new IOException("Illegal access to :" + fieldname + " in " + classname); | |||
| } catch (NullPointerException npe) { | |||
| @@ -20,10 +20,7 @@ package org.apache.tools.ant.types.resources; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import org.apache.tools.ant.util.FileUtils; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Resource; | |||
| import org.apache.tools.ant.types.Reference; | |||
| /** | |||
| * A Resource representation of something loadable via a Java classloader. | |||
| @@ -46,7 +43,7 @@ public class JavaResource extends AbstractClasspathResource { | |||
| */ | |||
| public JavaResource(String name, Path path) { | |||
| setName(name); | |||
| classpath = path; | |||
| setClasspath(path); | |||
| } | |||
| /** | |||
| @@ -76,14 +73,15 @@ public class JavaResource extends AbstractClasspathResource { | |||
| if (!getName().equals(otherjr.getName())) { | |||
| return getName().compareTo(otherjr.getName()); | |||
| } | |||
| if (loader != otherjr.loader) { | |||
| if (loader == null) { | |||
| if (getLoader() != otherjr.getLoader()) { | |||
| if (getLoader() == null) { | |||
| return -1; | |||
| } | |||
| if (otherjr.loader == null) { | |||
| if (otherjr.getLoader() == null) { | |||
| return 1; | |||
| } | |||
| return loader.getRefId().compareTo(otherjr.loader.getRefId()); | |||
| return getLoader().getRefId() | |||
| .compareTo(otherjr.getLoader().getRefId()); | |||
| } | |||
| Path p = getClasspath(); | |||
| Path op = otherjr.getClasspath(); | |||
| @@ -786,7 +786,7 @@ public class FileUtils { | |||
| /** | |||
| * Create a File object for a temporary file in a given directory. Without | |||
| * actually creating the file. | |||
| * | |||
| * | |||
| * <p> | |||
| * The file denoted by the returned abstract pathname did not exist before | |||
| * this method was invoked, any subsequent invocation of this method will | |||
| @@ -795,7 +795,7 @@ public class FileUtils { | |||
| * <p> | |||
| * The filename is prefixNNNNNsuffix where NNNN is a random number. | |||
| * </p> | |||
| * | |||
| * | |||
| * @param prefix | |||
| * prefix before the random number. | |||
| * @param suffix | |||
| @@ -803,8 +803,8 @@ public class FileUtils { | |||
| * @param parentDir | |||
| * Directory to create the temporary file in; java.io.tmpdir used | |||
| * if not specified. | |||
| * | |||
| * @deprecated since ant 1.7.1 use createTempFile(String, String, File, | |||
| * | |||
| * @deprecated since ant 1.7.1 use createTempFile(String, String, File, | |||
| * boolean, boolean) instead. | |||
| * @return a File reference to the new, nonexistent temporary file. | |||
| */ | |||
| @@ -836,7 +836,7 @@ public class FileUtils { | |||
| public File createTempFile(String prefix, String suffix, File parentDir, | |||
| boolean deleteOnExit, boolean createFile) { | |||
| File result = null; | |||
| String parent = (parentDir == null) | |||
| String parent = (parentDir == null) | |||
| ? System.getProperty("java.io.tmpdir") | |||
| : parentDir.getPath(); | |||
| @@ -866,7 +866,7 @@ public class FileUtils { | |||
| /** | |||
| * Create a File object for a temporary file in a given directory. Without | |||
| * actually creating the file. | |||
| * | |||
| * | |||
| * <p> | |||
| * The file denoted by the returned abstract pathname did not exist before | |||
| * this method was invoked, any subsequent invocation of this method will | |||
| @@ -875,7 +875,7 @@ public class FileUtils { | |||
| * <p> | |||
| * The filename is prefixNNNNNsuffix where NNNN is a random number. | |||
| * </p> | |||
| * | |||
| * | |||
| * @param prefix | |||
| * prefix before the random number. | |||
| * @param suffix | |||
| @@ -885,8 +885,8 @@ public class FileUtils { | |||
| * if not specified. | |||
| * @param deleteOnExit | |||
| * whether to set the tempfile for deletion on normal VM exit. | |||
| * | |||
| * @deprecated since ant 1.7.1 use createTempFile(String, String, File, | |||
| * | |||
| * @deprecated since ant 1.7.1 use createTempFile(String, String, File, | |||
| * boolean, boolean) instead. | |||
| * @return a File reference to the new, nonexistent temporary file. | |||
| */ | |||