summaryrefslogtreecommitdiff
path: root/src/main/org/apache/tools/ant/taskdefs/optional
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/org/apache/tools/ant/taskdefs/optional')
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java2
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java3
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java27
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java14
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java10
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java36
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java68
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java76
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java13
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/TestRequest.java1
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java8
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java29
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java4
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java33
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java12
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java10
18 files changed, 204 insertions, 158 deletions
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java b/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
index a7ad4a462..40e531c14 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/SchemaValidate.java
@@ -479,7 +479,7 @@ public class SchemaValidate extends XMLValidateTask {
public int hashCode() {
int result;
// CheckStyle:MagicNumber OFF
- result = namespace == null ? 0 : namespace.hashCode();
+ result = (namespace == null ? 0 : namespace.hashCode());
result = 29 * result + (file == null ? 0 : file.hashCode());
result = 29 * result + (url == null ? 0 : url.hashCode());
// CheckStyle:MagicNumber OFF
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
index 87f383dc7..ebfd50103 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
@@ -531,7 +531,6 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
* Log an error.
* @param e the exception to log.
*/
- @Override
public void error(final TransformerException e) {
logError(e, "Error");
}
@@ -540,7 +539,6 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
* Log a fatal error.
* @param e the exception to log.
*/
- @Override
public void fatalError(final TransformerException e) {
logError(e, "Fatal Error");
throw new BuildException("Fatal error during transformation using " + stylesheet + ": " + e.getMessageAndLocation(), e);
@@ -550,7 +548,6 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware
* Log a warning.
* @param e the exception to log.
*/
- @Override
public void warning(final TransformerException e) {
if (!suppressWarnings) {
logError(e, "Warning");
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
index 2d0391b56..c7000b3f9 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
@@ -364,7 +364,7 @@ public class XMLValidateTask extends Task {
* @return true when a SAX1 parser is in use
*/
protected boolean isSax1Parser() {
- return xmlReader instanceof ParserAdapter;
+ return (xmlReader instanceof ParserAdapter);
}
/**
@@ -599,7 +599,6 @@ public class XMLValidateTask extends Task {
* record a fatal error
* @param exception the fatal error
*/
- @Override
public void fatalError(SAXParseException exception) {
failed = true;
doLog(exception, Project.MSG_ERR);
@@ -608,7 +607,6 @@ public class XMLValidateTask extends Task {
* receive notification of a recoverable error
* @param exception the error
*/
- @Override
public void error(SAXParseException exception) {
failed = true;
doLog(exception, Project.MSG_ERR);
@@ -617,7 +615,6 @@ public class XMLValidateTask extends Task {
* receive notification of a warning
* @param exception the warning
*/
- @Override
public void warning(SAXParseException exception) {
// depending on implementation, XMLReader can yield hips of warning,
// only output then if user explicitly asked for it
@@ -627,6 +624,7 @@ public class XMLValidateTask extends Task {
}
private void doLog(SAXParseException e, int logLevel) {
+
log(getMessage(e), logLevel);
}
@@ -745,4 +743,6 @@ public class XMLValidateTask extends Task {
} // Property
+
+
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
index 4f2cf13a1..8b80cb8a3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
@@ -305,12 +305,15 @@ public class Depend extends MatchingTask {
List<String> dependencyList = null;
- // try to read the dependency info from the map if it is not out of date
- if (cache != null && cacheFileExists
+ if (cache != null) {
+ // try to read the dependency info from the map if it is
+ // not out of date
+ if (cacheFileExists
&& cacheLastModified > info.absoluteFile.lastModified()) {
- // depFile exists and is newer than the class file
- // need to get dependency list from the map.
- dependencyList = dependencyMap.get(info.className);
+ // depFile exists and is newer than the class file
+ // need to get dependency list from the map.
+ dependencyList = dependencyMap.get(info.className);
+ }
}
if (dependencyList == null) {
@@ -509,16 +512,20 @@ public class Depend extends MatchingTask {
* @param affectedClass the name of the affected .class file
* @param className the file that is triggering the out of dateness
*/
- private void warnOutOfDateButNotDeleted(ClassFileInfo affectedClassInfo, String affectedClass,
+ private void warnOutOfDateButNotDeleted(
+ ClassFileInfo affectedClassInfo, String affectedClass,
String className) {
if (affectedClassInfo.isUserWarned) {
return;
}
int level = Project.MSG_WARN;
- // downgrade warnings on RMI stublike classes, as they are generated by rmic,
- // so there is no need to tell the user that their source is missing.
- if (!warnOnRmiStubs && isRmiStub(affectedClass, className)) {
- level = Project.MSG_VERBOSE;
+ if (!warnOnRmiStubs) {
+ //downgrade warnings on RMI stublike classes, as they are generated
+ //by rmic, so there is no need to tell the user that their source is
+ //missing.
+ if (isRmiStub(affectedClass, className)) {
+ level = Project.MSG_VERBOSE;
+ }
}
log("The class " + affectedClass + " in file "
+ affectedClassInfo.absoluteFile.getPath()
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
index f20baabab..e68ddf05c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
@@ -157,10 +157,12 @@ public class DescriptorHandler extends HandlerBase {
return;
}
- if (getClass().getResource(location) != null && publicId != null) {
- resourceDTDs.put(publicId, location);
- owningTask.log("Mapped publicId " + publicId + " to resource "
+ if (getClass().getResource(location) != null) {
+ if (publicId != null) {
+ resourceDTDs.put(publicId, location);
+ owningTask.log("Mapped publicId " + publicId + " to resource "
+ location, Project.MSG_VERBOSE);
+ }
}
try {
@@ -381,8 +383,10 @@ public class DescriptorHandler extends HandlerBase {
}
// Get the value of the <ejb-name> tag. Only the first occurrence.
- if (currentElement.equals(EJB_NAME) && ejbName == null) {
- ejbName = currentText.trim();
+ if (currentElement.equals(EJB_NAME)) {
+ if (ejbName == null) {
+ ejbName = currentText.trim();
+ }
}
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
index 40a2b7c53..4484062fa 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
@@ -1081,7 +1081,12 @@ public class IPlanetEjbc {
* be run to bring the stubs and skeletons up to date.
*/
public boolean mustBeRecompiled(File destDir) {
- return destClassesModified(destDir) < sourceClassesModified(destDir);
+
+ long sourceModified = sourceClassesModified(destDir);
+
+ long destModified = destClassesModified(destDir);
+
+ return (destModified < sourceModified);
}
/**
@@ -1231,7 +1236,8 @@ public class IPlanetEjbc {
* names for the stubs and skeletons to be generated.
*/
private String[] classesToGenerate() {
- String[] classnames = iiop ? new String[NUM_CLASSES_WITH_IIOP]
+ String[] classnames = (iiop)
+ ? new String[NUM_CLASSES_WITH_IIOP]
: new String[NUM_CLASSES_WITHOUT_IIOP];
final String remotePkg = remote.getPackageName() + ".";
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
index ef3749f8f..33e125176 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
@@ -468,27 +468,29 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
String baseName = null;
- // try to find JOnAS specific convention name
- if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)
- && !descriptorFileName.contains(getConfig().baseNameTerminator)) {
+ if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) {
- // baseNameTerminator not found: the descriptor use the
- // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
- // not [Foo<baseNameTerminator>-ejb-jar.xml,
- // Foo<baseNameTerminator>-jonas-ejb-jar.xml].
+ // try to find JOnAS specific convention name
+ if (!descriptorFileName.contains(getConfig().baseNameTerminator)) {
- String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
- int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
- int endOfBaseName;
+ // baseNameTerminator not found: the descriptor use the
+ // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
+ // not [Foo<baseNameTerminator>-ejb-jar.xml,
+ // Foo<baseNameTerminator>-jonas-ejb-jar.xml].
- if (lastSeparatorIndex != -1) {
- endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
- } else {
- endOfBaseName = descriptorFileName.indexOf(".xml");
- }
+ String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
+ int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
+ int endOfBaseName;
- if (endOfBaseName != -1) {
- baseName = descriptorFileName.substring(0, endOfBaseName);
+ if (lastSeparatorIndex != -1) {
+ endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
+ } else {
+ endOfBaseName = descriptorFileName.indexOf(".xml");
+ }
+
+ if (endOfBaseName != -1) {
+ baseName = descriptorFileName.substring(0, endOfBaseName);
+ }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
index 1acb933ed..1000d8d41 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java
@@ -190,11 +190,12 @@ public final class Extension {
if (null == manifest) {
return new Extension[0];
}
- return Stream.concat(Optional.ofNullable(manifest.getMainAttributes())
- .map(Stream::of).orElse(Stream.empty()),
+ return Stream
+ .concat(Optional.ofNullable(manifest.getMainAttributes())
+ .map(Stream::of).orElse(Stream.empty()),
manifest.getEntries().values().stream())
- .map(attrs -> getExtension("", attrs)).filter(Objects::nonNull)
- .toArray(Extension[]::new);
+ .map(attrs -> getExtension("", attrs)).filter(Objects::nonNull)
+ .toArray(Extension[]::new);
}
/**
@@ -254,13 +255,15 @@ public final class Extension {
specificationVendor);
}
- final DeweyDecimal specificationVersion = extension.getSpecificationVersion();
+ final DeweyDecimal specificationVersion
+ = extension.getSpecificationVersion();
if (null != specificationVersion) {
attributes.putValue(prefix + SPECIFICATION_VERSION,
specificationVersion.toString());
}
- final String implementationVendorID = extension.getImplementationVendorID();
+ final String implementationVendorID
+ = extension.getImplementationVendorID();
if (null != implementationVendorID) {
attributes.putValue(prefix + IMPLEMENTATION_VENDOR_ID,
implementationVendorID);
@@ -272,7 +275,8 @@ public final class Extension {
implementationVendor);
}
- final DeweyDecimal implementationVersion = extension.getImplementationVersion();
+ final DeweyDecimal implementationVersion
+ = extension.getImplementationVersion();
if (null != implementationVersion) {
attributes.putValue(prefix + IMPLEMENTATION_VERSION,
implementationVersion.toString());
@@ -310,7 +314,8 @@ public final class Extension {
if (null != specificationVersion) {
try {
- this.specificationVersion = new DeweyDecimal(specificationVersion);
+ this.specificationVersion
+ = new DeweyDecimal(specificationVersion);
} catch (final NumberFormatException nfe) {
final String error = "Bad specification version format '"
+ specificationVersion + "' in '" + extensionName
@@ -418,24 +423,33 @@ public final class Extension {
}
// Available specification version must be >= required
- final DeweyDecimal requiredSpecificationVersion = required.getSpecificationVersion();
- if (null != requiredSpecificationVersion && (null == specificationVersion
- || !isCompatible(specificationVersion, requiredSpecificationVersion))) {
- return REQUIRE_SPECIFICATION_UPGRADE;
+ final DeweyDecimal requiredSpecificationVersion
+ = required.getSpecificationVersion();
+ if (null != requiredSpecificationVersion) {
+ if (null == specificationVersion
+ || !isCompatible(specificationVersion, requiredSpecificationVersion)) {
+ return REQUIRE_SPECIFICATION_UPGRADE;
+ }
}
// Implementation Vendor ID must match
- final String requiredImplementationVendorID = required.getImplementationVendorID();
- if (null != requiredImplementationVendorID && (null == implementationVendorID
- || !implementationVendorID.equals(requiredImplementationVendorID))) {
- return REQUIRE_VENDOR_SWITCH;
+ final String requiredImplementationVendorID
+ = required.getImplementationVendorID();
+ if (null != requiredImplementationVendorID) {
+ if (null == implementationVendorID
+ || !implementationVendorID.equals(requiredImplementationVendorID)) {
+ return REQUIRE_VENDOR_SWITCH;
+ }
}
// Implementation version must be >= required
- final DeweyDecimal requiredImplementationVersion = required.getImplementationVersion();
- if (null != requiredImplementationVersion && (null == implementationVersion
- || !isCompatible(implementationVersion, requiredImplementationVersion))) {
- return REQUIRE_IMPLEMENTATION_UPGRADE;
+ final DeweyDecimal requiredImplementationVersion
+ = required.getImplementationVersion();
+ if (null != requiredImplementationVersion) {
+ if (null == implementationVersion
+ || !isCompatible(implementationVersion, requiredImplementationVersion)) {
+ return REQUIRE_IMPLEMENTATION_UPGRADE;
+ }
}
// This available optional package satisfies the requirements
@@ -453,7 +467,7 @@ public final class Extension {
* @return true if the specified extension is compatible with this extension
*/
public boolean isCompatibleWith(final Extension required) {
- return COMPATIBLE == getCompatibilityWith(required);
+ return (COMPATIBLE == getCompatibilityWith(required));
}
/**
@@ -502,7 +516,8 @@ public final class Extension {
* @param first First version number (dotted decimal)
* @param second Second version number (dotted decimal)
*/
- private boolean isCompatible(final DeweyDecimal first, final DeweyDecimal second) {
+ private boolean isCompatible(final DeweyDecimal first,
+ final DeweyDecimal second) {
return first.isGreaterThanOrEqual(second);
}
@@ -515,7 +530,8 @@ public final class Extension {
* EXTENSION_LIST or OPTIONAL_EXTENSION_LIST)
* @return the list of listed extensions
*/
- private static Extension[] getListed(final Manifest manifest, final Attributes.Name listKey) {
+ private static Extension[] getListed(final Manifest manifest,
+ final Attributes.Name listKey) {
final List<Extension> results = new ArrayList<>();
final Attributes mainAttributes = manifest.getMainAttributes();
@@ -560,7 +576,8 @@ public final class Extension {
* @param onToken the token
* @return the resultant array
*/
- private static String[] split(final String string, final String onToken) {
+ private static String[] split(final String string,
+ final String onToken) {
final StringTokenizer tokenizer = new StringTokenizer(string, onToken);
final String[] result = new String[tokenizer.countTokens()];
@@ -583,7 +600,8 @@ public final class Extension {
* @param attributes Attributes to searched
* @return the new Extension object, or null
*/
- private static Extension getExtension(final String prefix, final Attributes attributes) {
+ private static Extension getExtension(final String prefix,
+ final Attributes attributes) {
//WARNING: We trim the values of all the attributes because
//Some extension declarations are badly defined (ie have spaces
//after version or vendorID)
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java b/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
index c55fa6967..931131b6b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/javah/JavahAdapterFactory.java
@@ -83,15 +83,15 @@ public class JavahAdapterFactory {
Path classpath)
throws BuildException {
if ((JavaEnvUtils.isKaffe() && choice == null)
- || Kaffeh.IMPLEMENTATION_NAME.equals(choice)) {
+ || Kaffeh.IMPLEMENTATION_NAME.equals(choice)) {
return new Kaffeh();
}
if ((JavaEnvUtils.isGij() && choice == null)
- || Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
+ || Gcjh.IMPLEMENTATION_NAME.equals(choice)) {
return new Gcjh();
}
- if (JavaEnvUtils.isAtLeastJavaVersion("10")
- && (choice == null || ForkingJavah.IMPLEMENTATION_NAME.equals(choice))) {
+ if (JavaEnvUtils.isAtLeastJavaVersion("10") &&
+ (choice == null || ForkingJavah.IMPLEMENTATION_NAME.equals(choice))) {
throw new BuildException("javah does not exist under Java 10 and higher,"
+ " use the javac task with nativeHeaderDir instead");
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
index 7e545e446..70c619889 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
@@ -1687,12 +1687,13 @@ public class JUnitTask extends Task {
* @since 1.9.8
*/
private void checkModules() {
- if ((hasPath(getCommandline().getModulepath())
- || hasPath(getCommandline().getUpgrademodulepath()))
- && (!batchTests.stream().allMatch(BaseTest::getFork)
- || !tests.stream().allMatch(BaseTest::getFork))) {
- throw new BuildException(
+ if (hasPath(getCommandline().getModulepath())
+ || hasPath(getCommandline().getUpgrademodulepath())) {
+ if (!batchTests.stream().allMatch(BaseTest::getFork)
+ || !tests.stream().allMatch(BaseTest::getFork)) {
+ throw new BuildException(
"The module path requires fork attribute to be set to true.");
+ }
}
}
@@ -1942,35 +1943,37 @@ public class JUnitTask extends Task {
private void createClassLoader() {
final Path userClasspath = getCommandline().getClasspath();
final Path userModulepath = getCommandline().getModulepath();
- if ((userClasspath != null || userModulepath != null) && (reloading || classLoader == null)) {
- deleteClassLoader();
- final Path path = new Path(getProject());
- if (userClasspath != null) {
- path.add((Path) userClasspath.clone());
- }
- if (userModulepath != null && !hasJunit(path)) {
- path.add(expandModulePath(userModulepath));
- }
- if (includeAntRuntime) {
- log("Implicitly adding " + antRuntimeClasses
+ if (userClasspath != null || userModulepath != null) {
+ if (reloading || classLoader == null) {
+ deleteClassLoader();
+ final Path path = new Path(getProject());
+ if (userClasspath != null) {
+ path.add((Path) userClasspath.clone());
+ }
+ if (userModulepath != null && !hasJunit(path)) {
+ path.add(expandModulePath(userModulepath));
+ }
+ if (includeAntRuntime) {
+ log("Implicitly adding " + antRuntimeClasses
+ " to CLASSPATH", Project.MSG_VERBOSE);
- path.append(antRuntimeClasses);
- }
- classLoader = getProject().createClassLoader(path);
- if (getClass().getClassLoader() != null
+ path.append(antRuntimeClasses);
+ }
+ classLoader = getProject().createClassLoader(path);
+ if (getClass().getClassLoader() != null
&& getClass().getClassLoader() != Project.class.getClassLoader()) {
- classLoader.setParent(getClass().getClassLoader());
- }
- classLoader.setParentFirst(false);
- classLoader.addJavaLibraries();
- log("Using CLASSPATH " + classLoader.getClasspath(),
+ classLoader.setParent(getClass().getClassLoader());
+ }
+ classLoader.setParentFirst(false);
+ classLoader.addJavaLibraries();
+ log("Using CLASSPATH " + classLoader.getClasspath(),
Project.MSG_VERBOSE);
- // make sure the test will be accepted as a TestCase
- classLoader.addSystemPackageRoot("junit");
- // make sure the test annotation are accepted
- classLoader.addSystemPackageRoot("org.junit");
- // will cause trouble in JDK 1.1 if omitted
- classLoader.addSystemPackageRoot("org.apache.tools.ant");
+ // make sure the test will be accepted as a TestCase
+ classLoader.addSystemPackageRoot("junit");
+ // make sure the test annotation are accepted
+ classLoader.addSystemPackageRoot("org.junit");
+ // will cause trouble in JDK 1.1 if omitted
+ classLoader.addSystemPackageRoot("org.apache.tools.ant");
+ }
}
}
@@ -2064,7 +2067,8 @@ public class JUnitTask extends Task {
*/
@Override
public boolean equals(final Object other) {
- if (other == null || other.getClass() != ForkedTestConfiguration.class) {
+ if (other == null
+ || other.getClass() != ForkedTestConfiguration.class) {
return false;
}
final ForkedTestConfiguration o = (ForkedTestConfiguration) other;
@@ -2072,9 +2076,13 @@ public class JUnitTask extends Task {
&& haltOnError == o.haltOnError
&& haltOnFailure == o.haltOnFailure
&& ((errorProperty == null && o.errorProperty == null)
- || (errorProperty != null && errorProperty.equals(o.errorProperty)))
+ ||
+ (errorProperty != null
+ && errorProperty.equals(o.errorProperty)))
&& ((failureProperty == null && o.failureProperty == null)
- || (failureProperty != null && failureProperty.equals(o.failureProperty)));
+ ||
+ (failureProperty != null
+ && failureProperty.equals(o.failureProperty)));
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
index 0e88fa8eb..e55856af5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/LauncherSupport.java
@@ -206,8 +206,8 @@ public class LauncherSupport {
final Optional<Project> project = this.testExecutionContext.getProject();
for (final ListenerDefinition applicableListener : applicableListenerElements) {
if (project.isPresent() && !applicableListener.shouldUse(project.get())) {
- log("Excluding listener " + applicableListener.getClassName() + " since it's not applicable"
- + " in the context of project", null, Project.MSG_DEBUG);
+ log("Excluding listener " + applicableListener.getClassName() + " since it's not applicable" +
+ " in the context of project", null, Project.MSG_DEBUG);
continue;
}
final TestExecutionListener listener = requireTestExecutionListener(applicableListener, classLoader);
@@ -274,8 +274,7 @@ public class LauncherSupport {
throw new BuildException("Failed to load listener class " + className, e);
}
if (!TestExecutionListener.class.isAssignableFrom(klass)) {
- throw new BuildException("Listener class " + className + " is not of type "
- + TestExecutionListener.class.getName());
+ throw new BuildException("Listener class " + className + " is not of type " + TestExecutionListener.class.getName());
}
try {
return (TestExecutionListener) klass.newInstance();
@@ -309,8 +308,7 @@ public class LauncherSupport {
// if the test is configured to halt on test failures, throw a build error
final String errorMessage;
if (test instanceof NamedTest) {
- errorMessage = "Test " + ((NamedTest) test).getName() + " has "
- + summary.getTestsFailedCount() + " failure(s)";
+ errorMessage = "Test " + ((NamedTest) test).getName() + " has " + summary.getTestsFailedCount() + " failure(s)";
} else {
errorMessage = "Some test(s) have failure(s)";
}
@@ -368,8 +366,7 @@ public class LauncherSupport {
final Thread sysErrStreamer = new Thread(streamer);
sysErrStreamer.setDaemon(true);
sysErrStreamer.setName("junitlauncher-syserr-stream-reader");
- sysErrStreamer.setUncaughtExceptionHandler((t, e) -> this.log("Failed in syserr streaming",
- e, Project.MSG_INFO));
+ sysErrStreamer.setUncaughtExceptionHandler((t, e) -> this.log("Failed in syserr streaming", e, Project.MSG_INFO));
sysErrStreamer.start();
break;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/TestRequest.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/TestRequest.java
index 2229c229b..ef15536d8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/TestRequest.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/TestRequest.java
@@ -82,7 +82,6 @@ final class TestRequest implements AutoCloseable {
return Collections.unmodifiableList(this.interestedInSysErr);
}
- @Override
public void close() throws Exception {
if (this.closables.isEmpty()) {
return;
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
index 12cef49b1..654211e75 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
@@ -87,8 +87,8 @@ public class JUnitLauncherTask extends Task {
final Project project = getProject();
for (final TestDefinition test : this.tests) {
if (!test.shouldRun(project)) {
- log("Excluding test " + test + " since it's considered not to run "
- + "in context of project " + project, Project.MSG_DEBUG);
+ log("Excluding test " + test + " since it's considered not to run " +
+ "in context of project " + project, Project.MSG_DEBUG);
continue;
}
if (test.getForkDefinition() != null) {
@@ -214,8 +214,8 @@ public class JUnitLauncherTask extends Task {
try {
projectPropsPath = dumpProjectProperties();
} catch (IOException e) {
- throw new BuildException("Could not create the necessary properties file while forking"
- + " a process for a test", e);
+ throw new BuildException("Could not create the necessary properties file while forking a process" +
+ " for a test", e);
}
// --properties <path-to-properties-file>
commandlineJava.createArgument().setValue(Constants.ARG_PROPERTIES);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index f977df6b5..901ff06a8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -710,25 +710,26 @@ public class FTP extends Task implements FTPTaskConfig {
boolean candidateFound = false;
String target = null;
for (int icounter = 0; icounter < array.length; icounter++) {
- if (array[icounter] != null && array[icounter].isDirectory()
- && !".".equals(array[icounter].getName())
+ if (array[icounter] != null && array[icounter].isDirectory()) {
+ if (!".".equals(array[icounter].getName())
&& !"..".equals(array[icounter].getName())) {
- candidateFound = true;
- target = fiddleName(array[icounter].getName());
- getProject().log("will try to cd to "
- + target + " where a directory called " + array[icounter].getName()
- + " exists", Project.MSG_DEBUG);
- for (int pcounter = 0; pcounter < array.length; pcounter++) {
- if (array[pcounter] != null
+ candidateFound = true;
+ target = fiddleName(array[icounter].getName());
+ getProject().log("will try to cd to "
+ + target + " where a directory called " + array[icounter].getName()
+ + " exists", Project.MSG_DEBUG);
+ for (int pcounter = 0; pcounter < array.length; pcounter++) {
+ if (array[pcounter] != null
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
- candidateFound = false;
+ candidateFound = false;
+ break;
+ }
+ }
+ if (candidateFound) {
break;
}
}
- if (candidateFound) {
- break;
- }
}
}
if (candidateFound) {
@@ -875,7 +876,7 @@ public class FTP extends Task implements FTPTaskConfig {
* @return true if the file exists
*/
public boolean exists() {
- return ftpFile != null;
+ return (ftpFile != null);
}
/**
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
index cd1c3831d..f7650be42 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
@@ -72,8 +72,8 @@ class FTPConfigurator {
if (!serverLanguageCodeConfig.isEmpty()
&& !FTPClientConfig.getSupportedLanguageCodes()
.contains(serverLanguageCodeConfig)) {
- throw new BuildException("unsupported language code"
- + serverLanguageCodeConfig);
+ throw new BuildException("unsupported language code" +
+ serverLanguageCodeConfig);
}
config.setServerLanguageCode(serverLanguageCodeConfig);
task.log("custom config: server language code = "
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 8ae95d6f2..0d877aaec 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -611,25 +611,26 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
boolean candidateFound = false;
String target = null;
for (int icounter = 0; icounter < array.length; icounter++) {
- if (array[icounter] != null && array[icounter].isDirectory()
- && !".".equals(array[icounter].getName())
+ if (array[icounter] != null && array[icounter].isDirectory()) {
+ if (!".".equals(array[icounter].getName())
&& !"..".equals(array[icounter].getName())) {
- candidateFound = true;
- target = fiddleName(array[icounter].getName());
- task.log("will try to cd to "
- + target + " where a directory called " + array[icounter].getName()
- + " exists", Project.MSG_DEBUG);
- for (int pcounter = 0; pcounter < array.length; pcounter++) {
- if (array[pcounter] != null
+ candidateFound = true;
+ target = fiddleName(array[icounter].getName());
+ task.log("will try to cd to "
+ + target + " where a directory called " + array[icounter].getName()
+ + " exists", Project.MSG_DEBUG);
+ for (int pcounter = 0; pcounter < array.length; pcounter++) {
+ if (array[pcounter] != null
&& pcounter != icounter
&& target.equals(array[pcounter].getName())) {
- candidateFound = false;
+ candidateFound = false;
+ break;
+ }
+ }
+ if (candidateFound) {
break;
}
}
- if (candidateFound) {
- break;
- }
}
}
if (candidateFound) {
@@ -1297,10 +1298,12 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
if (i >= 0) {
String cwd = ftp.printWorkingDirectory();
String parent = dir.getParent();
- if (parent != null && !ftp.changeWorkingDirectory(resolveFile(parent))) {
- throw new BuildException(
+ if (parent != null) {
+ if (!ftp.changeWorkingDirectory(resolveFile(parent))) {
+ throw new BuildException(
"could not change to directory: %s",
ftp.getReplyString());
+ }
}
while (i >= 0) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
index 59e53a03c..8c1ccf925 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessageBySftp.java
@@ -134,8 +134,10 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
final String remoteFile,
final File localFile) throws SftpException {
String pwd = remoteFile;
- if (remoteFile.lastIndexOf('/') != -1 && remoteFile.length() > 1) {
- pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
+ if (remoteFile.lastIndexOf('/') != -1) {
+ if (remoteFile.length() > 1) {
+ pwd = remoteFile.substring(0, remoteFile.lastIndexOf('/'));
+ }
}
channel.cd(pwd);
if (!localFile.exists()) {
@@ -166,8 +168,10 @@ public class ScpFromMessageBySftp extends ScpFromMessage {
if (!localFile.exists()) {
final String path = localFile.getAbsolutePath();
final int i = path.lastIndexOf(File.pathSeparator);
- if (i != -1 && path.length() > File.pathSeparator.length()) {
- new File(path.substring(0, i)).mkdirs();
+ if (i != -1) {
+ if (path.length() > File.pathSeparator.length()) {
+ new File(path.substring(0, i)).mkdirs();
+ }
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
index fd7285b76..ba74f44a1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
@@ -198,15 +198,16 @@ public class Symlink extends DispatchTask {
public void recreate() throws BuildException {
try {
if (fileSets.isEmpty()) {
- handleError("File set identifying link file(s) required for action recreate");
+ handleError(
+ "File set identifying link file(s) required for action recreate");
return;
}
final Properties links = loadLinks(fileSets);
for (final String lnk : links.stringPropertyNames()) {
final String res = links.getProperty(lnk);
try {
- if (Files.isSymbolicLink(Paths.get(lnk))
- && new File(lnk).getCanonicalPath().equals(new File(res).getCanonicalPath())) {
+ if (Files.isSymbolicLink(Paths.get(lnk)) &&
+ new File(lnk).getCanonicalPath().equals(new File(res).getCanonicalPath())) {
// it's already a symlink and the symlink target is the same
// as the target noted in the properties file. So there's no
// need to recreate it
@@ -215,8 +216,7 @@ public class Symlink extends DispatchTask {
continue;
}
} catch (IOException e) {
- final String errMessage = "Failed to check if path " + lnk
- + " is a symbolic link, linking to " + res;
+ final String errMessage = "Failed to check if path " + lnk + " is a symbolic link, linking to " + res;
if (failonerror) {
throw new BuildException(errMessage, e);
}