diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension')
19 files changed, 0 insertions, 3594 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Compatability.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Compatability.java deleted file mode 100644 index 2c06daf1..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Compatability.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -/** - * Enum used in (@link Extension) to indicate the compatibility - * of one extension to another. See (@link Extension) for instances - * of object. - * - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * This file is from excalibur.extension package. Dont edit this file - * directly as there is no unit tests to make sure it is operational - * in ant. Edit file in excalibur and run tests there before changing - * ants file. - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * - * @see Extension - */ -public final class Compatability { - /** - * A string representation of compatibility level. - */ - private final String name; - - /** - * Create a compatibility enum with specified name. - * - * @param name the name of compatibility level - */ - Compatability(final String name) { - this.name = name; - } - - /** - * Return name of compatibility level. - * - * @return the name of compatibility level - */ - public String toString() { - return name; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Compatibility.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Compatibility.java deleted file mode 100644 index bb28cd6b..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Compatibility.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -/** - * Enum used in (@link Extension) to indicate the compatibility - * of one extension to another. See (@link Extension) for instances - * of object. - * - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * This file is from excalibur.extension package. Dont edit this file - * directly as there is no unit tests to make sure it is operational - * in ant. Edit file in excalibur and run tests there before changing - * ants file. - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING - * - * @see Extension - */ -public final class Compatibility { - /** - * A string representation of compatibility level. - */ - private final String name; - - /** - * Create a compatibility enum with specified name. - * - * @param name the name of compatibility level - */ - Compatibility(final String name) { - this.name = name; - } - - /** - * Return name of compatibility level. - * - * @return the name of compatibility level - */ - public String toString() { - return name; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/DeweyDecimal.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/DeweyDecimal.java deleted file mode 100644 index 2edc2a78..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/DeweyDecimal.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - - -/** - * Utility class to contain version numbers in "Dewey Decimal" - * syntax. Numbers in the "Dewey Decimal" syntax consist of positive - * decimal integers separated by periods ".". For example, "2.0" or - * "1.2.3.4.5.6.7". This allows an extensible number to be used to - * represent major, minor, micro, etc versions. The version number - * must begin with a number. - * - * Original Implementation moved to org.apache.tools.ant.util.DeweyDecimal - * @deprecated use org.apache.tools.ant.util.DeweyDecimal instead. - * Deprecated since ant 1.8 - */ -public final class DeweyDecimal extends org.apache.tools.ant.util.DeweyDecimal { - - /** - * Construct a DeweyDecimal from an array of integer components. - * - * @param components an array of integer components. - */ - public DeweyDecimal(final int[] components) { - super(components); - } - - /** - * Construct a DeweyDecimal from string in DeweyDecimal format. - * - * @param string the string in dewey decimal format - * @exception NumberFormatException if string is malformed - */ - public DeweyDecimal(final String string) - throws NumberFormatException { - super(string); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java deleted file mode 100644 index d13d2f4e..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java +++ /dev/null @@ -1,690 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.jar.Attributes; -import java.util.jar.Manifest; - -import org.apache.tools.ant.util.DeweyDecimal; -import org.apache.tools.ant.util.StringUtils; - -/** - * <p>Utility class that represents either an available "Optional Package" - * (formerly known as "Standard Extension") as described in the manifest - * of a JAR file, or the requirement for such an optional package.</p> - * - * <p>For more information about optional packages, see the document - * <em>Optional Package Versioning</em> in the documentation bundle for your - * Java2 Standard Edition package, in file - * <code>guide/extensions/versioning.html</code>.</p> - * - */ -public final class Extension { - /** - * Manifest Attribute Name object for EXTENSION_LIST. - */ - public static final Attributes.Name EXTENSION_LIST - = new Attributes.Name("Extension-List"); - - /** - * <code>Name</code> object for <code>Optional-Extension-List</code> - * manifest attribute used for declaring optional dependencies on - * installed extensions. Note that the dependencies declared by this method - * are not required for the library to operate but if present will be used. - * It is NOT part of the official "Optional Package" specification. - * - * @see <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/spec.html#dependency"> - * Installed extension dependency</a> - */ - public static final Attributes.Name OPTIONAL_EXTENSION_LIST - = new Attributes.Name("Optional-Extension-List"); - - /** - * Manifest Attribute Name object for EXTENSION_NAME. - */ - public static final Attributes.Name EXTENSION_NAME = - new Attributes.Name("Extension-Name"); - /** - * Manifest Attribute Name object for SPECIFICATION_VERSION. - */ - public static final Attributes.Name SPECIFICATION_VERSION - = Attributes.Name.SPECIFICATION_VERSION; - - /** - * Manifest Attribute Name object for SPECIFICATION_VENDOR. - */ - public static final Attributes.Name SPECIFICATION_VENDOR - = Attributes.Name.SPECIFICATION_VENDOR; - - /** - * Manifest Attribute Name object for IMPLEMENTATION_VERSION. - */ - public static final Attributes.Name IMPLEMENTATION_VERSION - = Attributes.Name.IMPLEMENTATION_VERSION; - - /** - * Manifest Attribute Name object for IMPLEMENTATION_VENDOR. - */ - public static final Attributes.Name IMPLEMENTATION_VENDOR - = Attributes.Name.IMPLEMENTATION_VENDOR; - - /** - * Manifest Attribute Name object for IMPLEMENTATION_URL. - */ - public static final Attributes.Name IMPLEMENTATION_URL - = new Attributes.Name("Implementation-URL"); - - /** - * Manifest Attribute Name object for IMPLEMENTATION_VENDOR_ID. - */ - public static final Attributes.Name IMPLEMENTATION_VENDOR_ID - = new Attributes.Name("Implementation-Vendor-Id"); - - /** - * Enum indicating that extension is compatible with other extension. - */ - public static final Compatibility COMPATIBLE - = new Compatibility("COMPATIBLE"); - - /** - * Enum indicating that extension requires an upgrade - * of specification to be compatible with other extension. - */ - public static final Compatibility REQUIRE_SPECIFICATION_UPGRADE - = new Compatibility("REQUIRE_SPECIFICATION_UPGRADE"); - - /** - * Enum indicating that extension requires a vendor - * switch to be compatible with other extension. - */ - public static final Compatibility REQUIRE_VENDOR_SWITCH - = new Compatibility("REQUIRE_VENDOR_SWITCH"); - - /** - * Enum indicating that extension requires an upgrade - * of implementation to be compatible with other extension. - */ - public static final Compatibility REQUIRE_IMPLEMENTATION_UPGRADE - = new Compatibility("REQUIRE_IMPLEMENTATION_UPGRADE"); - - /** - * Enum indicating that extension is incompatible with - * other extension in ways other than other enums - * indicate). For example the other extension may have - * a different ID. - */ - public static final Compatibility INCOMPATIBLE - = new Compatibility("INCOMPATIBLE"); - - /** - * The name of the optional package being made available, or required. - */ - private String extensionName; - - /** - * The version number (dotted decimal notation) of the specification - * to which this optional package conforms. - */ - private DeweyDecimal specificationVersion; - - /** - * The name of the company or organization that originated the - * specification to which this optional package conforms. - */ - private String specificationVendor; - - /** - * The unique identifier of the company that produced the optional - * package contained in this JAR file. - */ - private String implementationVendorID; - - /** - * The name of the company or organization that produced this - * implementation of this optional package. - */ - private String implementationVendor; - - /** - * The version number (dotted decimal notation) for this implementation - * of the optional package. - */ - private DeweyDecimal implementationVersion; - - /** - * The URL from which the most recent version of this optional package - * can be obtained if it is not already installed. - */ - private String implementationURL; - - /** - * Return an array of <code>Extension</code> objects representing optional - * packages that are available in the JAR file associated with the - * specified <code>Manifest</code>. If there are no such optional - * packages, a zero-length array is returned. - * - * @param manifest Manifest to be parsed - * @return the "available" extensions in specified manifest - */ - public static Extension[] getAvailable(final Manifest manifest) { - if (null == manifest) { - return new Extension[ 0 ]; - } - - final ArrayList results = new ArrayList(); - - final Attributes mainAttributes = manifest.getMainAttributes(); - if (null != mainAttributes) { - final Extension extension = getExtension("", mainAttributes); - if (null != extension) { - results.add(extension); - } - } - - final Map entries = manifest.getEntries(); - final Iterator keys = entries.keySet().iterator(); - while (keys.hasNext()) { - final String key = (String) keys.next(); - final Attributes attributes = (Attributes) entries.get(key); - final Extension extension = getExtension("", attributes); - if (null != extension) { - results.add(extension); - } - } - - return (Extension[]) results.toArray(new Extension[results.size()]); - } - - /** - * Return the set of <code>Extension</code> objects representing optional - * packages that are required by the application contained in the JAR - * file associated with the specified <code>Manifest</code>. If there - * are no such optional packages, a zero-length list is returned. - * - * @param manifest Manifest to be parsed - * @return the dependencies that are specified in manifest - */ - public static Extension[] getRequired(final Manifest manifest) { - return getListed(manifest, Attributes.Name.EXTENSION_LIST); - } - - /** - * Return the set of <code>Extension</code> objects representing "Optional - * Packages" that the application declares they will use if present. If - * there are no such optional packages, a zero-length list is returned. - * - * @param manifest Manifest to be parsed - * @return the optional dependencies that are specified in manifest - */ - public static Extension[] getOptions(final Manifest manifest) { - return getListed(manifest, OPTIONAL_EXTENSION_LIST); - } - - /** - * Add Extension to the specified manifest Attributes. - * - * @param attributes the attributes of manifest to add to - * @param extension the extension - */ - public static void addExtension(final Extension extension, - final Attributes attributes) { - addExtension(extension, "", attributes); - } - - /** - * Add Extension to the specified manifest Attributes. - * Use the specified prefix so that dependencies can added - * with a prefix such as "java3d-" etc. - * - * @param attributes the attributes of manifest to add to - * @param extension the extension - * @param prefix the name to prefix to extension - */ - public static void addExtension(final Extension extension, - final String prefix, - final Attributes attributes) { - attributes.putValue(prefix + EXTENSION_NAME, - extension.getExtensionName()); - - final String specificationVendor = extension.getSpecificationVendor(); - if (null != specificationVendor) { - attributes.putValue(prefix + SPECIFICATION_VENDOR, - specificationVendor); - } - - final DeweyDecimal specificationVersion - = extension.getSpecificationVersion(); - if (null != specificationVersion) { - attributes.putValue(prefix + SPECIFICATION_VERSION, - specificationVersion.toString()); - } - - final String implementationVendorID - = extension.getImplementationVendorID(); - if (null != implementationVendorID) { - attributes.putValue(prefix + IMPLEMENTATION_VENDOR_ID, - implementationVendorID); - } - - final String implementationVendor = extension.getImplementationVendor(); - if (null != implementationVendor) { - attributes.putValue(prefix + IMPLEMENTATION_VENDOR, - implementationVendor); - } - - final DeweyDecimal implementationVersion - = extension.getImplementationVersion(); - if (null != implementationVersion) { - attributes.putValue(prefix + IMPLEMENTATION_VERSION, - implementationVersion.toString()); - } - - final String implementationURL = extension.getImplementationURL(); - if (null != implementationURL) { - attributes.putValue(prefix + IMPLEMENTATION_URL, - implementationURL); - } - } - - /** - * The constructor to create Extension object. - * Note that every component is allowed to be specified - * but only the extensionName is mandatory. - * - * @param extensionName the name of extension. - * @param specificationVersion the specification Version of extension. - * @param specificationVendor the specification Vendor of extension. - * @param implementationVersion the implementation Version of extension. - * @param implementationVendor the implementation Vendor of extension. - * @param implementationVendorId the implementation VendorId of extension. - * @param implementationURL the implementation URL of extension. - */ - public Extension(final String extensionName, - final String specificationVersion, - final String specificationVendor, - final String implementationVersion, - final String implementationVendor, - final String implementationVendorId, - final String implementationURL) { - this.extensionName = extensionName; - this.specificationVendor = specificationVendor; - - if (null != specificationVersion) { - try { - this.specificationVersion - = new DeweyDecimal(specificationVersion); - } catch (final NumberFormatException nfe) { - final String error = "Bad specification version format '" - + specificationVersion + "' in '" + extensionName - + "'. (Reason: " + nfe + ")"; - throw new IllegalArgumentException(error); - } - } - - this.implementationURL = implementationURL; - this.implementationVendor = implementationVendor; - this.implementationVendorID = implementationVendorId; - - if (null != implementationVersion) { - try { - this.implementationVersion - = new DeweyDecimal(implementationVersion); - } catch (final NumberFormatException nfe) { - final String error = "Bad implementation version format '" - + implementationVersion + "' in '" + extensionName - + "'. (Reason: " + nfe + ")"; - throw new IllegalArgumentException(error); - } - } - - if (null == this.extensionName) { - throw new NullPointerException("extensionName property is null"); - } - } - - /** - * Get the name of the extension. - * - * @return the name of the extension - */ - public String getExtensionName() { - return extensionName; - } - - /** - * Get the vendor of the extensions specification. - * - * @return the vendor of the extensions specification. - */ - public String getSpecificationVendor() { - return specificationVendor; - } - - /** - * Get the version of the extensions specification. - * - * @return the version of the extensions specification. - */ - public DeweyDecimal getSpecificationVersion() { - return specificationVersion; - } - - /** - * Get the url of the extensions implementation. - * - * @return the url of the extensions implementation. - */ - public String getImplementationURL() { - return implementationURL; - } - - /** - * Get the vendor of the extensions implementation. - * - * @return the vendor of the extensions implementation. - */ - public String getImplementationVendor() { - return implementationVendor; - } - - /** - * Get the vendorID of the extensions implementation. - * - * @return the vendorID of the extensions implementation. - */ - public String getImplementationVendorID() { - return implementationVendorID; - } - - /** - * Get the version of the extensions implementation. - * - * @return the version of the extensions implementation. - */ - public DeweyDecimal getImplementationVersion() { - return implementationVersion; - } - - /** - * Return a Compatibility enum indicating the relationship of this - * <code>Extension</code> with the specified <code>Extension</code>. - * - * @param required Description of the required optional package - * @return the enum indicating the compatibility (or lack thereof) - * of specified extension - */ - public Compatibility getCompatibilityWith(final Extension required) { - // Extension Name must match - if (!extensionName.equals(required.getExtensionName())) { - return INCOMPATIBLE; - } - - // Available specification version must be >= required - 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) { - if (null == implementationVendorID - || !implementationVendorID.equals(requiredImplementationVendorID)) { - return REQUIRE_VENDOR_SWITCH; - } - } - - // Implementation version must be >= required - 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 - return COMPATIBLE; - } - - /** - * Return <code>true</code> if the specified <code>Extension</code> - * (which represents an optional package required by an application) - * is satisfied by this <code>Extension</code> (which represents an - * optional package that is already installed. Otherwise, return - * <code>false</code>. - * - * @param required Description of the required optional package - * @return true if the specified extension is compatible with this extension - */ - public boolean isCompatibleWith(final Extension required) { - return (COMPATIBLE == getCompatibilityWith(required)); - } - - /** - * Return a String representation of this object. - * - * @return string representation of object. - */ - public String toString() { - final String brace = ": "; - - final StringBuffer sb = new StringBuffer(EXTENSION_NAME.toString()); - sb.append(brace); - sb.append(extensionName); - sb.append(StringUtils.LINE_SEP); - - if (null != specificationVersion) { - sb.append(SPECIFICATION_VERSION); - sb.append(brace); - sb.append(specificationVersion); - sb.append(StringUtils.LINE_SEP); - } - - if (null != specificationVendor) { - sb.append(SPECIFICATION_VENDOR); - sb.append(brace); - sb.append(specificationVendor); - sb.append(StringUtils.LINE_SEP); - } - - if (null != implementationVersion) { - sb.append(IMPLEMENTATION_VERSION); - sb.append(brace); - sb.append(implementationVersion); - sb.append(StringUtils.LINE_SEP); - } - - if (null != implementationVendorID) { - sb.append(IMPLEMENTATION_VENDOR_ID); - sb.append(brace); - sb.append(implementationVendorID); - sb.append(StringUtils.LINE_SEP); - } - - if (null != implementationVendor) { - sb.append(IMPLEMENTATION_VENDOR); - sb.append(brace); - sb.append(implementationVendor); - sb.append(StringUtils.LINE_SEP); - } - - if (null != implementationURL) { - sb.append(IMPLEMENTATION_URL); - sb.append(brace); - sb.append(implementationURL); - sb.append(StringUtils.LINE_SEP); - } - - return sb.toString(); - } - - /** - * Return <code>true</code> if the first version number is greater than - * or equal to the second; otherwise return <code>false</code>. - * - * @param first First version number (dotted decimal) - * @param second Second version number (dotted decimal) - */ - private boolean isCompatible(final DeweyDecimal first, - final DeweyDecimal second) { - return first.isGreaterThanOrEqual(second); - } - - /** - * Retrieve all the extensions listed under a particular key - * (Usually EXTENSION_LIST or OPTIONAL_EXTENSION_LIST). - * - * @param manifest the manifest to extract extensions from - * @param listKey the key used to get list (Usually - * EXTENSION_LIST or OPTIONAL_EXTENSION_LIST) - * @return the list of listed extensions - */ - private static Extension[] getListed(final Manifest manifest, - final Attributes.Name listKey) { - final ArrayList results = new ArrayList(); - final Attributes mainAttributes = manifest.getMainAttributes(); - - if (null != mainAttributes) { - getExtension(mainAttributes, results, listKey); - } - - final Map entries = manifest.getEntries(); - final Iterator keys = entries.keySet().iterator(); - while (keys.hasNext()) { - final String key = (String) keys.next(); - final Attributes attributes = (Attributes) entries.get(key); - getExtension(attributes, results, listKey); - } - - return (Extension[]) results.toArray(new Extension[results.size()]); - } - - /** - * Add required optional packages defined in the specified - * attributes entry, if any. - * - * @param attributes Attributes to be parsed - * @param required list to add required optional packages to - * @param listKey the key to use to lookup list, usually EXTENSION_LIST - * or OPTIONAL_EXTENSION_LIST - */ - private static void getExtension(final Attributes attributes, - final ArrayList required, - final Attributes.Name listKey) { - final String names = attributes.getValue(listKey); - if (null == names) { - return; - } - - final String[] extensions = split(names, " "); - for (int i = 0; i < extensions.length; i++) { - final String prefix = extensions[ i ] + "-"; - final Extension extension = getExtension(prefix, attributes); - - if (null != extension) { - required.add(extension); - } - } - } - - /** - * Splits the string on every token into an array of strings. - * - * @param string the string - * @param onToken the token - * @return the resultant array - */ - private static String[] split(final String string, - final String onToken) { - final StringTokenizer tokenizer = new StringTokenizer(string, onToken); - final String[] result = new String[ tokenizer.countTokens() ]; - - for (int i = 0; i < result.length; i++) { - result[ i ] = tokenizer.nextToken(); - } - - return result; - } - - /** - * Extract an Extension from Attributes. - * Prefix indicates the prefix checked for each string. - * Usually the prefix is <em>"<extension>-"</em> if looking for a - * <b>Required</b> extension. If you are looking for an - * <b>Available</b> extension - * then the prefix is <em>""</em>. - * - * @param prefix the prefix for each attribute name - * @param attributes Attributes to searched - * @return the new Extension object, or null - */ - 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) - final String nameKey = prefix + EXTENSION_NAME; - final String name = getTrimmedString(attributes.getValue(nameKey)); - if (null == name) { - return null; - } - - final String specVendorKey = prefix + SPECIFICATION_VENDOR; - final String specVendor - = getTrimmedString(attributes.getValue(specVendorKey)); - final String specVersionKey = prefix + SPECIFICATION_VERSION; - final String specVersion - = getTrimmedString(attributes.getValue(specVersionKey)); - - final String impVersionKey = prefix + IMPLEMENTATION_VERSION; - final String impVersion - = getTrimmedString(attributes.getValue(impVersionKey)); - final String impVendorKey = prefix + IMPLEMENTATION_VENDOR; - final String impVendor - = getTrimmedString(attributes.getValue(impVendorKey)); - final String impVendorIDKey = prefix + IMPLEMENTATION_VENDOR_ID; - final String impVendorId - = getTrimmedString(attributes.getValue(impVendorIDKey)); - final String impURLKey = prefix + IMPLEMENTATION_URL; - final String impURL = getTrimmedString(attributes.getValue(impURLKey)); - - return new Extension(name, specVersion, specVendor, impVersion, - impVendor, impVendorId, impURL); - } - - /** - * Trim the supplied string if the string is non-null - * - * @param value the string to trim or null - * @return the trimmed string or null - */ - private static String getTrimmedString(final String value) { - return null == value ? null : value.trim(); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java deleted file mode 100644 index b3cfddc2..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.util.DeweyDecimal; - -/** - * Simple class that represents an Extension and conforms to Ants - * patterns. - * - * @ant.datatype name="extension" - */ -public class ExtensionAdapter extends DataType { - /** - * The name of the optional package being made available, or required. - */ - private String extensionName; - - /** - * The version number (dotted decimal notation) of the specification - * to which this optional package conforms. - */ - private DeweyDecimal specificationVersion; - - /** - * The name of the company or organization that originated the - * specification to which this optional package conforms. - */ - private String specificationVendor; - - /** - * The unique identifier of the company that produced the optional - * package contained in this JAR file. - */ - private String implementationVendorID; - - /** - * The name of the company or organization that produced this - * implementation of this optional package. - */ - private String implementationVendor; - - /** - * The version number (dotted decimal notation) for this implementation - * of the optional package. - */ - private DeweyDecimal implementationVersion; - - /** - * The URL from which the most recent version of this optional package - * can be obtained if it is not already installed. - */ - private String implementationURL; - - /** - * Set the name of extension. - * - * @param extensionName the name of extension - */ - public void setExtensionName(final String extensionName) { - verifyNotAReference(); - this.extensionName = extensionName; - } - - /** - * Set the specificationVersion of extension. - * - * @param specificationVersion the specificationVersion of extension - */ - public void setSpecificationVersion(final String specificationVersion) { - verifyNotAReference(); - this.specificationVersion = new DeweyDecimal(specificationVersion); - } - - /** - * Set the specificationVendor of extension. - * - * @param specificationVendor the specificationVendor of extension - */ - public void setSpecificationVendor(final String specificationVendor) { - verifyNotAReference(); - this.specificationVendor = specificationVendor; - } - - /** - * Set the implementationVendorID of extension. - * - * @param implementationVendorID the implementationVendorID of extension - */ - public void setImplementationVendorId(final String implementationVendorID) { - verifyNotAReference(); - this.implementationVendorID = implementationVendorID; - } - - /** - * Set the implementationVendor of extension. - * - * @param implementationVendor the implementationVendor of extension - */ - public void setImplementationVendor(final String implementationVendor) { - verifyNotAReference(); - this.implementationVendor = implementationVendor; - } - - /** - * Set the implementationVersion of extension. - * - * @param implementationVersion the implementationVersion of extension - */ - public void setImplementationVersion(final String implementationVersion) { - verifyNotAReference(); - this.implementationVersion = new DeweyDecimal(implementationVersion); - } - - /** - * Set the implementationURL of extension. - * - * @param implementationURL the implementationURL of extension - */ - public void setImplementationUrl(final String implementationURL) { - verifyNotAReference(); - this.implementationURL = implementationURL; - } - - /** - * Makes this instance in effect a reference to another ExtensionAdapter - * instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference.</p> - * - * @param reference the reference to which this instance is associated - * @exception BuildException if this instance already has been configured. - */ - public void setRefid(final Reference reference) - throws BuildException { - if (null != extensionName - || null != specificationVersion - || null != specificationVendor - || null != implementationVersion - || null != implementationVendorID - || null != implementationVendor - || null != implementationURL) { - throw tooManyAttributes(); - } - super.setRefid(reference); - } - - private void verifyNotAReference() - throws BuildException { - if (isReference()) { - throw tooManyAttributes(); - } - } - - /** - * Convert this adpater object into an extension object. - * - * @return the extension object - */ - Extension toExtension() - throws BuildException { - if (isReference()) { - return ((ExtensionAdapter) getCheckedRef()).toExtension(); - } - dieOnCircularReference(); - if (null == extensionName) { - final String message = "Extension is missing name."; - throw new BuildException(message); - } - - String specificationVersionString = null; - if (null != specificationVersion) { - specificationVersionString = specificationVersion.toString(); - } - String implementationVersionString = null; - if (null != implementationVersion) { - implementationVersionString = implementationVersion.toString(); - } - return new Extension(extensionName, - specificationVersionString, - specificationVendor, - implementationVersionString, - implementationVendor, - implementationVendorID, - implementationURL); - } - - /** - * a debug toString method. - * @return the extension in a string. - * @see java.lang.Object#toString() - */ - public String toString() { - return "{" + toExtension().toString() + "}"; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionResolver.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionResolver.java deleted file mode 100644 index a73282ec..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionResolver.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * Interface to locate a File that satisfies extension. - * - */ -public interface ExtensionResolver { - /** - * Attempt to locate File that satisfies - * extension via resolver. - * - * @param extension the extension - * @param project the Ant project instance - * @return the File satisfying extension, null - * if can not resolve extension - * @throws BuildException if error occurs attempting to - * resolve extension - */ - File resolve(Extension extension, Project project) - throws BuildException; -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionSet.java deleted file mode 100644 index 5aba37c9..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionSet.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.Stack; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.Reference; - -/** - * The Extension set lists a set of "Optional Packages" / - * "Extensions". - * - * @ant.datatype name="extension-set" - */ -public class ExtensionSet - extends DataType { - /** - * ExtensionAdapter objects representing extensions. - */ - private final ArrayList extensions = new ArrayList(); - - /** - * Filesets specifying all the extensions wanted. - */ - private final ArrayList extensionsFilesets = new ArrayList(); - - /** - * Adds an extension that this library requires. - * - * @param extensionAdapter an extension that this library requires. - */ - public void addExtension(final ExtensionAdapter extensionAdapter) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - extensions.add(extensionAdapter); - } - - /** - * Adds a set of files about which extensions data will be extracted. - * - * @param fileSet a set of files about which extensions data will be extracted. - */ - public void addLibfileset(final LibFileSet fileSet) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - extensionsFilesets.add(fileSet); - } - - /** - * Adds a set of files about which extensions data will be extracted. - * - * @param fileSet a set of files about which extensions data will be extracted. - */ - public void addFileset(final FileSet fileSet) { - if (isReference()) { - throw noChildrenAllowed(); - } - setChecked(false); - extensionsFilesets.add(fileSet); - } - - /** - * Extract a set of Extension objects from the ExtensionSet. - * - * @param proj the project instance. - * @return an array containing the Extensions from this set - * @throws BuildException if an error occurs - */ - public Extension[] toExtensions(final Project proj) - throws BuildException { - if (isReference()) { - return ((ExtensionSet) getCheckedRef()).toExtensions(proj); - } - dieOnCircularReference(); - final ArrayList extensionsList = ExtensionUtil.toExtensions(extensions); - ExtensionUtil.extractExtensions(proj, extensionsList, extensionsFilesets); - return (Extension[]) extensionsList.toArray(new Extension[extensionsList.size()]); - } - - /** - * Makes this instance in effect a reference to another ExtensionSet - * instance. - * - * <p>You must not set another attribute or nest elements inside - * this element if you make it a reference.</p> - * - * @param reference the reference to which this instance is associated - * @exception BuildException if this instance already has been configured. - */ - @Override - public void setRefid(final Reference reference) - throws BuildException { - if (!extensions.isEmpty() || !extensionsFilesets.isEmpty()) { - throw tooManyAttributes(); - } - super.setRefid(reference); - } - - @Override - protected synchronized void dieOnCircularReference(Stack stk, Project p) - throws BuildException { - if (isChecked()) { - return; - } - if (isReference()) { - super.dieOnCircularReference(stk, p); - } else { - for (Iterator i = extensions.iterator(); i.hasNext();) { - pushAndInvokeCircularReferenceCheck((ExtensionAdapter) i.next(), - stk, p); - } - for (Iterator i = extensionsFilesets.iterator(); i.hasNext();) { - pushAndInvokeCircularReferenceCheck((FileSet) i.next(), stk, p); - } - setChecked(true); - } - } - - /** - * @see java.lang.Object#toString() - * @return the extensions in a string. - */ - @Override - public String toString() { - return "ExtensionSet" + Arrays.asList(toExtensions(getProject())); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java deleted file mode 100644 index 089c7894..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.jar.JarFile; -import java.util.jar.Manifest; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.FileSet; - -/** - * A set of useful methods relating to extensions. - * - */ -public final class ExtensionUtil { - /** - * Class is not meant to be instantiated. - */ - private ExtensionUtil() { - //all methods static - } - - /** - * Convert a list of extensionAdapter objects to extensions. - * - * @param adapters the list of ExtensionAdapterss to add to convert - * @throws BuildException if an error occurs - */ - static ArrayList toExtensions(final List adapters) - throws BuildException { - final ArrayList results = new ArrayList(); - - final int size = adapters.size(); - for (int i = 0; i < size; i++) { - final ExtensionAdapter adapter = - (ExtensionAdapter) adapters.get(i); - final Extension extension = adapter.toExtension(); - results.add(extension); - } - - return results; - } - - /** - * Generate a list of extensions from a specified fileset. - * - * @param libraries the list to add extensions to - * @param fileset the filesets containing librarys - * @throws BuildException if an error occurs - */ - static void extractExtensions(final Project project, - final List libraries, - final List fileset) - throws BuildException { - if (!fileset.isEmpty()) { - final Extension[] extensions = getExtensions(project, - fileset); - for (int i = 0; i < extensions.length; i++) { - libraries.add(extensions[ i ]); - } - } - } - - /** - * Retrieve extensions from the specified libraries. - * - * @param libraries the filesets for libraries - * @return the extensions contained in libraries - * @throws BuildException if failing to scan libraries - */ - private static Extension[] getExtensions(final Project project, - final List libraries) - throws BuildException { - final ArrayList extensions = new ArrayList(); - final Iterator iterator = libraries.iterator(); - while (iterator.hasNext()) { - final FileSet fileSet = (FileSet) iterator.next(); - - boolean includeImpl = true; - boolean includeURL = true; - - if (fileSet instanceof LibFileSet) { - LibFileSet libFileSet = (LibFileSet) fileSet; - includeImpl = libFileSet.isIncludeImpl(); - includeURL = libFileSet.isIncludeURL(); - } - - final DirectoryScanner scanner = fileSet.getDirectoryScanner(project); - final File basedir = scanner.getBasedir(); - final String[] files = scanner.getIncludedFiles(); - for (int i = 0; i < files.length; i++) { - final File file = new File(basedir, files[ i ]); - loadExtensions(file, extensions, includeImpl, includeURL); - } - } - return (Extension[]) extensions.toArray(new Extension[extensions.size()]); - } - - /** - * Load list of available extensions from specified file. - * - * @param file the file - * @param extensionList the list to add available extensions to - * @throws BuildException if there is an error - */ - private static void loadExtensions(final File file, - final List extensionList, - final boolean includeImpl, - final boolean includeURL) - throws BuildException { - try { - final JarFile jarFile = new JarFile(file); - final Extension[] extensions = - Extension.getAvailable(jarFile.getManifest()); - for (int i = 0; i < extensions.length; i++) { - final Extension extension = extensions[ i ]; - addExtension(extensionList, extension, includeImpl, includeURL); - } - } catch (final Exception e) { - throw new BuildException(e.getMessage(), e); - } - } - - /** - * Add extension to list. - * If extension should not have implementation details but - * does strip them. If extension should not have url but does - * then strip it. - * - * @param extensionList the list of extensions to add to - * @param originalExtension the extension - * @param includeImpl false to exclude implementation details - * @param includeURL false to exclude implementation URL - */ - private static void addExtension(final List extensionList, - final Extension originalExtension, - final boolean includeImpl, - final boolean includeURL) { - Extension extension = originalExtension; - if (!includeURL - && null != extension.getImplementationURL()) { - extension = - new Extension(extension.getExtensionName(), - extension.getSpecificationVersion().toString(), - extension.getSpecificationVendor(), - extension.getImplementationVersion().toString(), - extension.getImplementationVendor(), - extension.getImplementationVendorID(), - null); - } - - final boolean hasImplAttributes = - null != extension.getImplementationURL() - || null != extension.getImplementationVersion() - || null != extension.getImplementationVendorID() - || null != extension.getImplementationVendor(); - - if (!includeImpl && hasImplAttributes) { - extension = - new Extension(extension.getExtensionName(), - extension.getSpecificationVersion().toString(), - extension.getSpecificationVendor(), - null, - null, - null, - extension.getImplementationURL()); - } - - extensionList.add(extension); - } - - /** - * Retrieve manifest for specified file. - * - * @param file the file - * @return the manifest - * @throws BuildException if errror occurs (file doesn't exist, - * file not a jar, manifest doesn't exist in file) - */ - static Manifest getManifest(final File file) - throws BuildException { - try { - final JarFile jarFile = new JarFile(file); - Manifest m = jarFile.getManifest(); - if (m == null) { - throw new BuildException(file + " doesn't have a MANIFEST"); - } - return m; - } catch (final IOException ioe) { - throw new BuildException(ioe.getMessage(), ioe); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtraAttribute.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtraAttribute.java deleted file mode 100644 index d52bec41..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtraAttribute.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import org.apache.tools.ant.BuildException; - -/** - * Simple holder for extra attributes in main section of manifest. - * - * @todo Refactor this and all the other parameter, sysproperty, - * property etc into a single class in framework - */ -public class ExtraAttribute { - private String name; - private String value; - - /** - * Set the name of the parameter. - * - * @param name the name of parameter - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Set the value of the parameter. - * - * @param value the parameter value - */ - public void setValue(final String value) { - this.value = value; - } - - /** - * Retrieve name of parameter. - * - * @return the name of parameter. - */ - String getName() { - return name; - } - - /** - * Retrieve the value of parameter. - * - * @return the value of parameter. - */ - String getValue() { - return value; - } - - /** - * Make sure that neither the name or the value - * is null. - * - * @throws BuildException if the attribute is invalid. - */ - public void validate() throws BuildException { - if (null == name) { - final String message = "Missing name from parameter."; - throw new BuildException(message); - } else if (null == value) { - final String message = "Missing value from parameter " + name + "."; - throw new BuildException(message); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibAvailableTask.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibAvailableTask.java deleted file mode 100644 index cebcf0d5..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibAvailableTask.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.io.File; -import java.util.Iterator; -import java.util.Vector; -import java.util.jar.Manifest; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; - -/** - * Checks whether an extension is present in a fileset or an extensionSet. - * - * @ant.task name="jarlib-available" - */ -public class JarLibAvailableTask extends Task { - /** - * The library to display information about. - */ - private File libraryFile; - - /** - * Filesets specifying all the librarys - * to display information about. - */ - private final Vector extensionFileSets = new Vector(); - - /** - * The name of the property to set if extension is available. - */ - private String propertyName; - - /** - * The extension that is required. - */ - private ExtensionAdapter requiredExtension; - - /** - * The name of property to set if extensions are available. - * - * @param property The name of property to set if extensions is available. - */ - public void setProperty(final String property) { - this.propertyName = property; - } - - /** - * The JAR library to check. - * - * @param file The jar library to check. - */ - public void setFile(final File file) { - this.libraryFile = file; - } - - /** - * Set the Extension looking for. - * - * @param extension Set the Extension looking for. - */ - public void addConfiguredExtension(final ExtensionAdapter extension) { - if (null != requiredExtension) { - final String message = "Can not specify extension to " - + "search for multiple times."; - throw new BuildException(message); - } - requiredExtension = extension; - } - - /** - * Adds a set of extensions to search in. - * - * @param extensionSet a set of extensions to search in. - */ - public void addConfiguredExtensionSet(final ExtensionSet extensionSet) { - extensionFileSets.addElement(extensionSet); - } - - /** - * Execute the task. - * - * @throws BuildException if something goes wrong. - */ - public void execute() throws BuildException { - validate(); - - final Extension test = requiredExtension.toExtension(); - - // Check if list of files to check has been specified - if (!extensionFileSets.isEmpty()) { - final Iterator iterator = extensionFileSets.iterator(); - while (iterator.hasNext()) { - final ExtensionSet extensionSet - = (ExtensionSet) iterator.next(); - final Extension[] extensions = - extensionSet.toExtensions(getProject()); - for (int i = 0; i < extensions.length; i++) { - final Extension extension = extensions[ i ]; - if (extension.isCompatibleWith(test)) { - getProject().setNewProperty(propertyName, "true"); - } - } - } - } else { - final Manifest manifest = ExtensionUtil.getManifest(libraryFile); - final Extension[] extensions = Extension.getAvailable(manifest); - for (int i = 0; i < extensions.length; i++) { - final Extension extension = extensions[ i ]; - if (extension.isCompatibleWith(test)) { - getProject().setNewProperty(propertyName, "true"); - } - } - } - } - - /** - * Validate the tasks parameters. - * - * @throws BuildException if invalid parameters found - */ - private void validate() throws BuildException { - if (null == requiredExtension) { - final String message = "Extension element must be specified."; - throw new BuildException(message); - } - - if (null == libraryFile && extensionFileSets.isEmpty()) { - final String message = "File attribute not specified."; - throw new BuildException(message); - } - if (null != libraryFile && !libraryFile.exists()) { - final String message = "File '" + libraryFile + "' does not exist."; - throw new BuildException(message); - } - if (null != libraryFile && !libraryFile.isFile()) { - final String message = "\'" + libraryFile + "\' is not a file."; - throw new BuildException(message); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibDisplayTask.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibDisplayTask.java deleted file mode 100644 index da12cd02..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibDisplayTask.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.io.File; -import java.util.Iterator; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.FileSet; - -/** - * Displays the "Optional Package" and "Package Specification" information - * contained within the specified JARs. - * - * <p>Prior to JDK1.3, an "Optional Package" was known as an Extension. - * The specification for this mechanism is available in the JDK1.3 - * documentation in the directory - * $JDK_HOME/docs/guide/extensions/versioning.html. Alternatively it is - * available online at <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html"> - * http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html</a>.</p> - * - * @ant.task name="jarlib-display" - */ -public class JarLibDisplayTask extends Task { - /** - * The library to display information about. - */ - private File libraryFile; - - /** - * Filesets specifying all the librarys - * to display information about. - */ - private final Vector libraryFileSets = new Vector(); - - /** - * The JAR library to display information for. - * - * @param file The jar library to display information for. - */ - public void setFile(final File file) { - this.libraryFile = file; - } - - /** - * Adds a set of files about which library data will be displayed. - * - * @param fileSet a set of files about which library data will be displayed. - */ - public void addFileset(final FileSet fileSet) { - libraryFileSets.addElement(fileSet); - } - - /** - * Execute the task. - * - * @throws BuildException if the task fails. - */ - public void execute() throws BuildException { - validate(); - - final LibraryDisplayer displayer = new LibraryDisplayer(); - // Check if list of files to check has been specified - if (!libraryFileSets.isEmpty()) { - final Iterator iterator = libraryFileSets.iterator(); - while (iterator.hasNext()) { - final FileSet fileSet = (FileSet) iterator.next(); - final DirectoryScanner scanner - = fileSet.getDirectoryScanner(getProject()); - final File basedir = scanner.getBasedir(); - final String[] files = scanner.getIncludedFiles(); - for (int i = 0; i < files.length; i++) { - final File file = new File(basedir, files[ i ]); - displayer.displayLibrary(file); - } - } - } else { - displayer.displayLibrary(libraryFile); - } - } - - /** - * Validate the tasks parameters. - * - * @throws BuildException if invalid parameters found - */ - private void validate() throws BuildException { - if (null == libraryFile && libraryFileSets.isEmpty()) { - final String message = "File attribute not specified."; - throw new BuildException(message); - } - if (null != libraryFile && !libraryFile.exists()) { - final String message = "File '" + libraryFile + "' does not exist."; - throw new BuildException(message); - } - if (null != libraryFile && !libraryFile.isFile()) { - final String message = "\'" + libraryFile + "\' is not a file."; - throw new BuildException(message); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java deleted file mode 100644 index 5afc57f1..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.jar.Attributes; -import java.util.jar.Manifest; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.MagicNames; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; - -/** - * Generates a manifest that declares all the dependencies. - * The dependencies are determined by looking in the - * specified path and searching for Extension / "Optional Package" - * specifications in the manifests of the jars. - * - * <p>Prior to JDK1.3, an "Optional Package" was known as an Extension. - * The specification for this mechanism is available in the JDK1.3 - * documentation in the directory - * $JDK_HOME/docs/guide/extensions/versioning.html. Alternatively it is - * available online at <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html"> - * http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html</a>.</p> - * - * @ant.task name="jarlib-manifest" - */ -public final class JarLibManifestTask extends Task { - /** - * Version of manifest spec that task generates. - */ - private static final String MANIFEST_VERSION = "1.0"; - - /** - * "Created-By" string used when creating manifest. - */ - private static final String CREATED_BY = "Created-By"; - - /** - * The library to display information about. - */ - private File destFile; - - /** - * The extension supported by this library (if any). - */ - private Extension extension; - - /** - * ExtensionAdapter objects representing - * dependencies required by library. - */ - private final ArrayList dependencies = new ArrayList(); - - /** - * ExtensionAdapter objects representing optional - * dependencies required by library. - */ - private final ArrayList optionals = new ArrayList(); - - /** - * Extra attributes the user specifies for main section - * in manifest. - */ - private final ArrayList extraAttributes = new ArrayList(); - - /** - * The location where generated manifest is placed. - * - * @param destFile The location where generated manifest is placed. - */ - public void setDestfile(final File destFile) { - this.destFile = destFile; - } - - /** - * Adds an extension that this library implements. - * - * @param extensionAdapter an extension that this library implements. - * - * @throws BuildException if there is multiple extensions detected - * in the library. - */ - public void addConfiguredExtension(final ExtensionAdapter extensionAdapter) - throws BuildException { - if (null != extension) { - throw new BuildException("Can not have multiple extensions defined in one library."); - } - extension = extensionAdapter.toExtension(); - } - - /** - * Adds a set of extensions that this library requires. - * - * @param extensionSet a set of extensions that this library requires. - */ - public void addConfiguredDepends(final ExtensionSet extensionSet) { - dependencies.add(extensionSet); - } - - /** - * Adds a set of extensions that this library optionally requires. - * - * @param extensionSet a set of extensions that this library optionally requires. - */ - public void addConfiguredOptions(final ExtensionSet extensionSet) { - optionals.add(extensionSet); - } - - /** - * Adds an attribute that is to be put in main section of manifest. - * - * @param attribute an attribute that is to be put in main section of manifest. - */ - public void addConfiguredAttribute(final ExtraAttribute attribute) { - extraAttributes.add(attribute); - } - - /** - * Execute the task. - * - * @throws BuildException if the task fails. - */ - public void execute() throws BuildException { - validate(); - - final Manifest manifest = new Manifest(); - final Attributes attributes = manifest.getMainAttributes(); - - attributes.put(Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION); - attributes.putValue(CREATED_BY, "Apache Ant " - + getProject().getProperty(MagicNames.ANT_VERSION)); - - appendExtraAttributes(attributes); - - if (null != extension) { - Extension.addExtension(extension, attributes); - } - - //Add all the dependency data to manifest for dependencies - final ArrayList depends = toExtensions(dependencies); - appendExtensionList(attributes, Extension.EXTENSION_LIST, "lib", depends.size()); - appendLibraryList(attributes, "lib", depends); - - // Add all the dependency data to manifest for "optional" - //dependencies - final ArrayList option = toExtensions(optionals); - appendExtensionList(attributes, Extension.OPTIONAL_EXTENSION_LIST, "opt", option.size()); - appendLibraryList(attributes, "opt", option); - - try { - log("Generating manifest " + destFile.getAbsoluteFile(), Project.MSG_INFO); - writeManifest(manifest); - } catch (final IOException ioe) { - throw new BuildException(ioe.getMessage(), ioe); - } - } - - /** - * Validate the tasks parameters. - * - * @throws BuildException if invalid parameters found - */ - private void validate() throws BuildException { - if (null == destFile) { - throw new BuildException("Destfile attribute not specified."); - } - if (destFile.exists() && !destFile.isFile()) { - throw new BuildException(destFile + " is not a file."); - } - } - - /** - * Add any extra attributes to the manifest. - * - * @param attributes the manifest section to write - * attributes to - */ - private void appendExtraAttributes(final Attributes attributes) { - final Iterator iterator = extraAttributes.iterator(); - while (iterator.hasNext()) { - final ExtraAttribute attribute = - (ExtraAttribute) iterator.next(); - attributes.putValue(attribute.getName(), - attribute.getValue()); - } - } - - /** - * Write out manifest to destfile. - * - * @param manifest the manifest - * @throws IOException if error writing file - */ - private void writeManifest(final Manifest manifest) throws IOException { - FileOutputStream output = null; - try { - output = new FileOutputStream(destFile); - manifest.write(output); - output.flush(); - } finally { - if (null != output) { - try { - output.close(); - } catch (IOException e) { - // ignore - } - } - } - } - - /** - * Append specified extensions to specified attributes. - * Use the extensionKey to list the extensions, usually "Extension-List:" - * for required dependencies and "Optional-Extension-List:" for optional - * dependencies. NOTE: "Optional" dependencies are not part of the - * specification. - * - * @param attributes the attributes to add extensions to - * @param extensions the list of extensions - * @throws BuildException if an error occurs - */ - private void appendLibraryList(final Attributes attributes, final String listPrefix, - final ArrayList extensions) throws BuildException { - final int size = extensions.size(); - for (int i = 0; i < size; i++) { - final Extension ext = (Extension) extensions.get(i); - final String prefix = listPrefix + i + "-"; - Extension.addExtension(ext, prefix, attributes); - } - } - - /** - * Append an attribute such as "Extension-List: lib0 lib1 lib2" - * using specified prefix and counting up to specified size. - * Also use specified extensionKey so that can generate list of - * optional dependencies as well. - * - * @param size the number of librarys to list - * @param listPrefix the prefix for all librarys - * @param attributes the attributes to add key-value to - * @param extensionKey the key to use - */ - private void appendExtensionList(final Attributes attributes, - final Attributes.Name extensionKey, final String listPrefix, final int size) { - final StringBuffer sb = new StringBuffer(); - for (int i = 0; i < size; i++) { - sb.append(listPrefix); - sb.append(i); - sb.append(' '); - } - //add in something like - //"Extension-List: javahelp java3d" - attributes.put(extensionKey, sb.toString()); - } - - /** - * Convert a list of ExtensionSet objects to extensions. - * - * @param extensionSets the list of ExtensionSets to add to list - * @throws BuildException if an error occurs - */ - private ArrayList toExtensions(final ArrayList extensionSets) throws BuildException { - final ArrayList results = new ArrayList(); - - final int size = extensionSets.size(); - for (int i = 0; i < size; i++) { - final ExtensionSet set = (ExtensionSet) extensionSets.get(i); - final Extension[] extensions = set.toExtensions(getProject()); - for (int j = 0; j < extensions.length; j++) { - results.add(extensions[ j ]); - } - } - return results; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java deleted file mode 100644 index c13194fa..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.io.File; -import java.util.ArrayList; -import java.util.jar.Manifest; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.optional.extension.resolvers.AntResolver; -import org.apache.tools.ant.taskdefs.optional.extension.resolvers.LocationResolver; -import org.apache.tools.ant.taskdefs.optional.extension.resolvers.URLResolver; - -/** - * Tries to locate a JAR to satisfy an extension and place - * location of JAR into property. - * - * @ant.task name="jarlib-resolve" - */ -public class JarLibResolveTask extends Task { - /** - * The name of the property in which the location of - * library is stored. - */ - private String propertyName; - - /** - * The extension that is required. - */ - private Extension requiredExtension; - - /** - * The set of resolvers to use to attempt to locate library. - */ - private final ArrayList resolvers = new ArrayList(); - - /** - * Flag to indicate that you should check that - * the librarys resolved actually contain - * extension and if they don't then raise - * an exception. - */ - private boolean checkExtension = true; - - /** - * Flag indicating whether or not you should - * throw a BuildException if you cannot resolve - * library. - */ - private boolean failOnError = true; - - /** - * The name of the property in which the location of - * library is stored. - * - * @param property The name of the property in which the location of - * library is stored. - */ - public void setProperty(final String property) { - this.propertyName = property; - } - - /** - * Check nested libraries for extensions - * - * @param checkExtension if true, libraries returned by nested - * resolvers should be checked to see if they supply extension. - */ - public void setCheckExtension(final boolean checkExtension) { - this.checkExtension = checkExtension; - } - - /** - * Set whether to fail if error. - * - * @param failOnError if true, failure to locate library should fail build. - */ - public void setFailOnError(final boolean failOnError) { - this.failOnError = failOnError; - } - - /** - * Adds location resolver to look for a library in a location - * relative to project directory. - * - * @param loc the resolver location to search. - */ - public void addConfiguredLocation(final LocationResolver loc) { - resolvers.add(loc); - } - - /** - * Adds a URL resolver to download a library from a URL - * to a local file. - * - * @param url the URL resolver from which to download the library - */ - public void addConfiguredUrl(final URLResolver url) { - resolvers.add(url); - } - - /** - * Adds Ant resolver to run an Ant build file to generate a library. - * - * @param ant the AntResolver to generate the library. - */ - public void addConfiguredAnt(final AntResolver ant) { - resolvers.add(ant); - } - - /** - * Set the Extension looking for. - * - * @param extension Set the Extension looking for. - */ - public void addConfiguredExtension(final ExtensionAdapter extension) { - if (null != requiredExtension) { - final String message = "Can not specify extension to " - + "resolve multiple times."; - throw new BuildException(message); - } - requiredExtension = extension.toExtension(); - } - - /** - * Execute the task. - * - * @throws BuildException if the task fails. - */ - public void execute() throws BuildException { - validate(); - - getProject().log("Resolving extension: " + requiredExtension, Project.MSG_VERBOSE); - - String candidate = getProject().getProperty(propertyName); - - if (null != candidate) { - final String message = "Property Already set to: " + candidate; - if (failOnError) { - throw new BuildException(message); - } - getProject().log(message, Project.MSG_ERR); - return; - } - - final int size = resolvers.size(); - for (int i = 0; i < size; i++) { - final ExtensionResolver resolver = - (ExtensionResolver) resolvers.get(i); - - getProject().log("Searching for extension using Resolver:" + resolver, - Project.MSG_VERBOSE); - - try { - final File file = resolver.resolve(requiredExtension, getProject()); - try { - checkExtension(file); - return; - } catch (final BuildException be) { - final String message = "File " + file + " returned by " - + "resolver failed to satisfy extension due to: " + be.getMessage(); - getProject().log(message, Project.MSG_WARN); - } - } catch (final BuildException be) { - final String message = "Failed to resolve extension to file " + "using resolver " - + resolver + " due to: " + be; - getProject().log(message, Project.MSG_WARN); - } - } - missingExtension(); - } - - /** - * Utility method that will throw a {@link BuildException} - * if {@link #failOnError} is true else it just displays - * a warning. - */ - private void missingExtension() { - final String message = "Unable to resolve extension to a file"; - if (failOnError) { - throw new BuildException(message); - } - getProject().log(message, Project.MSG_ERR); - } - - /** - * Check if specified file satisfies extension. - * If it does then set the relevant property - * else throw a BuildException. - * - * @param file the candidate library - * @throws BuildException if library does not satisfy extension - */ - private void checkExtension(final File file) { - if (!file.exists()) { - throw new BuildException("File " + file + " does not exist"); - } - if (!file.isFile()) { - throw new BuildException("File " + file + " is not a file"); - } - if (!checkExtension) { - getProject().log("Setting property to " + file - + " without verifying library satisfies extension", Project.MSG_VERBOSE); - setLibraryProperty(file); - } else { - getProject().log("Checking file " + file + " to see if it satisfies extension", - Project.MSG_VERBOSE); - final Manifest manifest = ExtensionUtil.getManifest(file); - final Extension[] extensions = Extension.getAvailable(manifest); - for (int i = 0; i < extensions.length; i++) { - final Extension extension = extensions[ i ]; - if (extension.isCompatibleWith(requiredExtension)) { - setLibraryProperty(file); - return; - } - } - final String message = "File " + file + " skipped as it " - + "does not satisfy extension"; - getProject().log(message, Project.MSG_VERBOSE); - throw new BuildException(message); - } - } - - /** - * Utility method to set the appropriate property - * to indicate that specified file satisfies library - * requirements. - * - * @param file the library - */ - private void setLibraryProperty(final File file) { - getProject().setNewProperty(propertyName, file.getAbsolutePath()); - } - - /** - * Validate the tasks parameters. - * - * @throws BuildException if invalid parameters found - */ - private void validate() throws BuildException { - if (null == propertyName) { - final String message = "Property attribute must be specified."; - throw new BuildException(message); - } - - if (null == requiredExtension) { - final String message = "Extension element must be specified."; - throw new BuildException(message); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibFileSet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibFileSet.java deleted file mode 100644 index b21719e5..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibFileSet.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import org.apache.tools.ant.types.FileSet; - -/** - * LibFileSet represents a fileset containing libraries. - * Associated with the libraries is data pertaining to - * how they are to be handled when building manifests. - * - */ -public class LibFileSet - extends FileSet { - /** - * Flag indicating whether should include the - * "Implementation-URL" attribute in manifest. - * Defaults to false. - */ - private boolean includeURL; - - /** - * Flag indicating whether should include the - * "Implementation-*" attributes in manifest. - * Defaults to false. - */ - private boolean includeImpl; - - /** - * String that is the base URL for the librarys - * when constructing the "Implementation-URL" - * attribute. For instance setting the base to - * "http://jakarta.apache.org/avalon/libs/" and then - * including the library "excalibur-cli-1.0.jar" in the - * fileset will result in the "Implementation-URL" attribute - * being set to "http://jakarta.apache.org/avalon/libs/excalibur-cli-1.0.jar" - * - * Note this is only used if the library does not define - * "Implementation-URL" itself. - * - * Note that this also implies includeURL=true - */ - private String urlBase; - - /** - * Flag indicating whether should include the - * "Implementation-URL" attribute in manifest. - * Defaults to false. - * - * @param includeURL the flag - */ - public void setIncludeUrl(boolean includeURL) { - this.includeURL = includeURL; - } - - /** - * Flag indicating whether should include the - * "Implementation-*" attributes in manifest. - * Defaults to false. - * - * @param includeImpl the flag - */ - public void setIncludeImpl(boolean includeImpl) { - this.includeImpl = includeImpl; - } - - /** - * Set the url base for fileset. - * - * @param urlBase the base url - */ - public void setUrlBase(String urlBase) { - this.urlBase = urlBase; - } - - /** - * Get the includeURL flag. - * - * @return the includeURL flag. - */ - boolean isIncludeURL() { - return includeURL; - } - - /** - * Get the includeImpl flag. - * - * @return the includeImpl flag. - */ - boolean isIncludeImpl() { - return includeImpl; - } - - /** - * Get the urlbase. - * - * @return the urlbase. - */ - String getUrlBase() { - return urlBase; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java deleted file mode 100644 index b0ee4f81..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/LibraryDisplayer.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.io.File; -import java.text.ParseException; -import java.util.jar.Manifest; - -import org.apache.tools.ant.BuildException; - -/** - * Utility class to output the information in a jar relating - * to "Optional Packages" (formely known as "Extensions") - * and Package Specifications. - * - */ -class LibraryDisplayer { - /** - * Display the extensions and specifications contained - * within specified file. - * - * @param file the file - * @throws BuildException if fail to read file - */ - void displayLibrary(final File file) - throws BuildException { - final Manifest manifest = ExtensionUtil.getManifest(file); - displayLibrary(file, manifest); - } - - /** - * Display the extensions and specifications contained - * within specified file. - * - * @param file the file to use while reporting - * @param manifest the manifest of file - * @throws BuildException if fail to read file - */ - void displayLibrary(final File file, - final Manifest manifest) - throws BuildException { - final Extension[] available = Extension.getAvailable(manifest); - final Extension[] required = Extension.getRequired(manifest); - final Extension[] options = Extension.getOptions(manifest); - final Specification[] specifications = getSpecifications(manifest); - - if (0 == available.length && 0 == required.length && 0 == options.length - && 0 == specifications.length) { - return; - } - - final String message = "File: " + file; - final int size = message.length(); - printLine(size); - System.out.println(message); - printLine(size); - if (0 != available.length) { - System.out.println("Extensions Supported By Library:"); - for (int i = 0; i < available.length; i++) { - final Extension extension = available[ i ]; - System.out.println(extension.toString()); - } - } - - if (0 != required.length) { - System.out.println("Extensions Required By Library:"); - for (int i = 0; i < required.length; i++) { - final Extension extension = required[ i ]; - System.out.println(extension.toString()); - } - } - - if (0 != options.length) { - System.out.println("Extensions that will be used by Library if present:"); - for (int i = 0; i < options.length; i++) { - final Extension extension = options[ i ]; - System.out.println(extension.toString()); - } - } - - if (0 != specifications.length) { - System.out.println("Specifications Supported By Library:"); - for (int i = 0; i < specifications.length; i++) { - final Specification specification = specifications[ i ]; - displaySpecification(specification); - } - } - } - - /** - * Print out a line of '-'s equal to specified size. - * - * @param size the number of dashes to printout - */ - private void printLine(final int size) { - for (int i = 0; i < size; i++) { - System.out.print("-"); - } - System.out.println(); - } - - /** - * Get specifications from manifest. - * - * @param manifest the manifest - * @return the specifications or null if none - * @throws BuildException if malformed specification sections - */ - private Specification[] getSpecifications(final Manifest manifest) - throws BuildException { - try { - return Specification.getSpecifications(manifest); - } catch (final ParseException pe) { - throw new BuildException(pe.getMessage(), pe); - } - } - - /** - * Print out specification details. - * - * @param specification the specification - */ - private void displaySpecification(final Specification specification) { - final String[] sections = specification.getSections(); - if (null != sections) { - final StringBuffer sb = new StringBuffer("Sections: "); - for (int i = 0; i < sections.length; i++) { - sb.append(" "); - sb.append(sections[ i ]); - } - System.out.println(sb); - } - System.out.println(specification.toString()); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java deleted file mode 100644 index 1e4bb7b3..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java +++ /dev/null @@ -1,605 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension; - -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.Map; -import java.util.jar.Attributes; -import java.util.jar.Manifest; - -import org.apache.tools.ant.util.DeweyDecimal; -import org.apache.tools.ant.util.StringUtils; - -/** - * <p>Utility class that represents either an available "Optional Package" - * (formerly known as "Standard Extension") as described in the manifest - * of a JAR file, or the requirement for such an optional package.</p> - * - * <p>For more information about optional packages, see the document - * <em>Optional Package Versioning</em> in the documentation bundle for your - * Java2 Standard Edition package, in file - * <code>guide/extensions/versioning.html</code>.</p> - * - */ -public final class Specification { - - private static final String MISSING = "Missing "; - - /** - * Manifest Attribute Name object for SPECIFICATION_TITLE. - */ - public static final Attributes.Name SPECIFICATION_TITLE - = Attributes.Name.SPECIFICATION_TITLE; - - /** - * Manifest Attribute Name object for SPECIFICATION_VERSION. - */ - public static final Attributes.Name SPECIFICATION_VERSION - = Attributes.Name.SPECIFICATION_VERSION; - - /** - * Manifest Attribute Name object for SPECIFICATION_VENDOR. - */ - public static final Attributes.Name SPECIFICATION_VENDOR - = Attributes.Name.SPECIFICATION_VENDOR; - - /** - * Manifest Attribute Name object for IMPLEMENTATION_TITLE. - */ - public static final Attributes.Name IMPLEMENTATION_TITLE - = Attributes.Name.IMPLEMENTATION_TITLE; - - /** - * Manifest Attribute Name object for IMPLEMENTATION_VERSION. - */ - public static final Attributes.Name IMPLEMENTATION_VERSION - = Attributes.Name.IMPLEMENTATION_VERSION; - - /** - * Manifest Attribute Name object for IMPLEMENTATION_VENDOR. - */ - public static final Attributes.Name IMPLEMENTATION_VENDOR - = Attributes.Name.IMPLEMENTATION_VENDOR; - - /** - * Enum indicating that extension is compatible with other Package - * Specification. - */ - public static final Compatibility COMPATIBLE = - new Compatibility("COMPATIBLE"); - - /** - * Enum indicating that extension requires an upgrade - * of specification to be compatible with other Package Specification. - */ - public static final Compatibility REQUIRE_SPECIFICATION_UPGRADE = - new Compatibility("REQUIRE_SPECIFICATION_UPGRADE"); - - /** - * Enum indicating that extension requires a vendor - * switch to be compatible with other Package Specification. - */ - public static final Compatibility REQUIRE_VENDOR_SWITCH = - new Compatibility("REQUIRE_VENDOR_SWITCH"); - - /** - * Enum indicating that extension requires an upgrade - * of implementation to be compatible with other Package Specification. - */ - public static final Compatibility REQUIRE_IMPLEMENTATION_CHANGE = - new Compatibility("REQUIRE_IMPLEMENTATION_CHANGE"); - - /** - * This enum indicates that an extension is incompatible with - * other Package Specification in ways other than other enums - * indicate. For example, the other Package Specification - * may have a different ID. - */ - public static final Compatibility INCOMPATIBLE = - new Compatibility("INCOMPATIBLE"); - - /** - * The name of the Package Specification. - */ - private String specificationTitle; - - /** - * The version number (dotted decimal notation) of the specification - * to which this optional package conforms. - */ - private DeweyDecimal specificationVersion; - - /** - * The name of the company or organization that originated the - * specification to which this specification conforms. - */ - private String specificationVendor; - - /** - * The title of implementation. - */ - private String implementationTitle; - - /** - * The name of the company or organization that produced this - * implementation of this specification. - */ - private String implementationVendor; - - /** - * The version string for implementation. The version string is - * opaque. - */ - private String implementationVersion; - - /** - * The sections of jar that the specification applies to. - */ - private String[] sections; - - /** - * Return an array of <code>Package Specification</code> objects. - * If there are no such optional packages, a zero-length array is returned. - * - * @param manifest Manifest to be parsed - * @return the Package Specifications extensions in specified manifest - * @throws ParseException if the attributes of the specifications cannot - * be parsed according to their expected formats. - */ - public static Specification[] getSpecifications(final Manifest manifest) - throws ParseException { - if (null == manifest) { - return new Specification[ 0 ]; - } - - final ArrayList results = new ArrayList(); - - final Map entries = manifest.getEntries(); - final Iterator keys = entries.keySet().iterator(); - while (keys.hasNext()) { - final String key = (String) keys.next(); - final Attributes attributes = (Attributes) entries.get(key); - final Specification specification - = getSpecification(key, attributes); - if (null != specification) { - results.add(specification); - } - } - - final ArrayList trimmedResults = removeDuplicates(results); - return (Specification[]) trimmedResults.toArray(new Specification[trimmedResults.size()]); - } - - /** - * The constructor to create Package Specification object. - * Note that every component is allowed to be specified - * but only the specificationTitle is mandatory. - * - * @param specificationTitle the name of specification. - * @param specificationVersion the specification Version. - * @param specificationVendor the specification Vendor. - * @param implementationTitle the title of implementation. - * @param implementationVersion the implementation Version. - * @param implementationVendor the implementation Vendor. - */ - public Specification(final String specificationTitle, - final String specificationVersion, - final String specificationVendor, - final String implementationTitle, - final String implementationVersion, - final String implementationVendor) { - this(specificationTitle, specificationVersion, specificationVendor, - implementationTitle, implementationVersion, implementationVendor, - null); - } - - /** - * The constructor to create Package Specification object. - * Note that every component is allowed to be specified - * but only the specificationTitle is mandatory. - * - * @param specificationTitle the name of specification. - * @param specificationVersion the specification Version. - * @param specificationVendor the specification Vendor. - * @param implementationTitle the title of implementation. - * @param implementationVersion the implementation Version. - * @param implementationVendor the implementation Vendor. - * @param sections the sections/packages that Specification applies to. - */ - public Specification(final String specificationTitle, - final String specificationVersion, - final String specificationVendor, - final String implementationTitle, - final String implementationVersion, - final String implementationVendor, - final String[] sections) { - this.specificationTitle = specificationTitle; - this.specificationVendor = specificationVendor; - - if (null != specificationVersion) { - try { - this.specificationVersion - = new DeweyDecimal(specificationVersion); - } catch (final NumberFormatException nfe) { - final String error = "Bad specification version format '" - + specificationVersion + "' in '" + specificationTitle - + "'. (Reason: " + nfe + ")"; - throw new IllegalArgumentException(error); - } - } - - this.implementationTitle = implementationTitle; - this.implementationVendor = implementationVendor; - this.implementationVersion = implementationVersion; - - if (null == this.specificationTitle) { - throw new NullPointerException("specificationTitle"); - } - - String[] copy = null; - if (null != sections) { - copy = new String[ sections.length ]; - System.arraycopy(sections, 0, copy, 0, sections.length); - } - this.sections = copy; - } - - /** - * Get the title of the specification. - * - * @return the title of specification - */ - public String getSpecificationTitle() { - return specificationTitle; - } - - /** - * Get the vendor of the specification. - * - * @return the vendor of the specification. - */ - public String getSpecificationVendor() { - return specificationVendor; - } - - /** - * Get the title of the specification. - * - * @return the title of the specification. - */ - public String getImplementationTitle() { - return implementationTitle; - } - - /** - * Get the version of the specification. - * - * @return the version of the specification. - */ - public DeweyDecimal getSpecificationVersion() { - return specificationVersion; - } - - /** - * Get the vendor of the extensions implementation. - * - * @return the vendor of the extensions implementation. - */ - public String getImplementationVendor() { - return implementationVendor; - } - - /** - * Get the version of the implementation. - * - * @return the version of the implementation. - */ - public String getImplementationVersion() { - return implementationVersion; - } - - /** - * Return an array containing sections to which specification applies - * or null if relevant to no sections. - * - * @return an array containing sections to which specification applies - * or null if relevant to no sections. - */ - public String[] getSections() { - if (null == sections) { - return null; - } - final String[] newSections = new String[ sections.length ]; - System.arraycopy(sections, 0, newSections, 0, sections.length); - return newSections; - } - - /** - * Return a Compatibility enum indicating the relationship of this - * <code>Package Specification</code> with the specified - * <code>Extension</code>. - * - * @param other the other specification - * @return the enum indicating the compatibility (or lack thereof) - * of specified Package Specification - */ - public Compatibility getCompatibilityWith(final Specification other) { - // Specification Name must match - if (!specificationTitle.equals(other.getSpecificationTitle())) { - return INCOMPATIBLE; - } - - // Available specification version must be >= required - final DeweyDecimal otherSpecificationVersion - = other.getSpecificationVersion(); - if (null != specificationVersion) { - if (null == otherSpecificationVersion - || !isCompatible(specificationVersion, otherSpecificationVersion)) { - return REQUIRE_SPECIFICATION_UPGRADE; - } - } - - // Implementation Vendor ID must match - final String otherImplementationVendor - = other.getImplementationVendor(); - if (null != implementationVendor) { - if (null == otherImplementationVendor - || !implementationVendor.equals(otherImplementationVendor)) { - return REQUIRE_VENDOR_SWITCH; - } - } - - // Implementation version must be >= required - final String otherImplementationVersion - = other.getImplementationVersion(); - if (null != implementationVersion) { - if (null == otherImplementationVersion - || !implementationVersion.equals(otherImplementationVersion)) { - return REQUIRE_IMPLEMENTATION_CHANGE; - } - } - - // This available optional package satisfies the requirements - return COMPATIBLE; - } - - /** - * Return <code>true</code> if the specified <code>package</code> - * is satisfied by this <code>Specification</code>. Otherwise, return - * <code>false</code>. - * - * @param other the specification - * @return true if the specification is compatible with this specification - */ - public boolean isCompatibleWith(final Specification other) { - return (COMPATIBLE == getCompatibilityWith(other)); - } - - /** - * Return a String representation of this object. - * - * @return string representation of object. - */ - public String toString() { - final String brace = ": "; - - final StringBuffer sb - = new StringBuffer(SPECIFICATION_TITLE.toString()); - sb.append(brace); - sb.append(specificationTitle); - sb.append(StringUtils.LINE_SEP); - - if (null != specificationVersion) { - sb.append(SPECIFICATION_VERSION); - sb.append(brace); - sb.append(specificationVersion); - sb.append(StringUtils.LINE_SEP); - } - - if (null != specificationVendor) { - sb.append(SPECIFICATION_VENDOR); - sb.append(brace); - sb.append(specificationVendor); - sb.append(StringUtils.LINE_SEP); - } - - if (null != implementationTitle) { - sb.append(IMPLEMENTATION_TITLE); - sb.append(brace); - sb.append(implementationTitle); - sb.append(StringUtils.LINE_SEP); - } - - if (null != implementationVersion) { - sb.append(IMPLEMENTATION_VERSION); - sb.append(brace); - sb.append(implementationVersion); - sb.append(StringUtils.LINE_SEP); - } - - if (null != implementationVendor) { - sb.append(IMPLEMENTATION_VENDOR); - sb.append(brace); - sb.append(implementationVendor); - sb.append(StringUtils.LINE_SEP); - } - - return sb.toString(); - } - - /** - * Return <code>true</code> if the first version number is greater than - * or equal to the second; otherwise return <code>false</code>. - * - * @param first First version number (dotted decimal) - * @param second Second version number (dotted decimal) - */ - private boolean isCompatible(final DeweyDecimal first, - final DeweyDecimal second) { - return first.isGreaterThanOrEqual(second); - } - - /** - * Combine all specifications objects that are identical except - * for the sections. - * - * <p>Note this is very inefficent and should probably be fixed - * in the future.</p> - * - * @param list the array of results to trim - * @return an array list with all duplicates removed - */ - private static ArrayList removeDuplicates(final ArrayList list) { - final ArrayList results = new ArrayList(); - final ArrayList sections = new ArrayList(); - while (list.size() > 0) { - final Specification specification = (Specification) list.remove(0); - final Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - final Specification other = (Specification) iterator.next(); - if (isEqual(specification, other)) { - final String[] otherSections = other.getSections(); - if (null != otherSections) { - sections.addAll(Arrays.asList(otherSections)); - } - iterator.remove(); - } - } - - final Specification merged = - mergeInSections(specification, sections); - results.add(merged); - //Reset list of sections - sections.clear(); - } - - return results; - } - - /** - * Test if two specifications are equal except for their sections. - * - * @param specification one specificaiton - * @param other the ohter specification - * @return true if two specifications are equal except for their - * sections, else false - */ - private static boolean isEqual(final Specification specification, - final Specification other) { - return - specification.getSpecificationTitle().equals(other.getSpecificationTitle()) - && specification.getSpecificationVersion().isEqual(other.getSpecificationVersion()) - && specification.getSpecificationVendor().equals(other.getSpecificationVendor()) - && specification.getImplementationTitle().equals(other.getImplementationTitle()) - && specification.getImplementationVersion().equals(other.getImplementationVersion()) - && specification.getImplementationVendor().equals(other.getImplementationVendor()); - } - - /** - * Merge the specified sections into specified section and return result. - * If no sections to be added then just return original specification. - * - * @param specification the specification - * @param sectionsToAdd the list of sections to merge - * @return the merged specification - */ - private static Specification mergeInSections(final Specification specification, - final ArrayList sectionsToAdd) { - if (0 == sectionsToAdd.size()) { - return specification; - } - sectionsToAdd.addAll(Arrays.asList(specification.getSections())); - - final String[] sections = - (String[]) sectionsToAdd.toArray(new String[sectionsToAdd.size()]); - - return new Specification(specification.getSpecificationTitle(), - specification.getSpecificationVersion().toString(), - specification.getSpecificationVendor(), - specification.getImplementationTitle(), - specification.getImplementationVersion(), - specification.getImplementationVendor(), - sections); - } - - /** - * Trim the supplied string if the string is non-null - * - * @param value the string to trim or null - * @return the trimmed string or null - */ - private static String getTrimmedString(final String value) { - return value == null ? null : value.trim(); - } - - /** - * Extract an Package Specification from Attributes. - * - * @param attributes Attributes to searched - * @return the new Specification object, or null - */ - private static Specification getSpecification(final String section, - final Attributes attributes) - throws ParseException { - //WARNING: We trim the values of all the attributes because - //Some extension declarations are badly defined (ie have spaces - //after version or vendor) - final String name - = getTrimmedString(attributes.getValue(SPECIFICATION_TITLE)); - if (null == name) { - return null; - } - - final String specVendor - = getTrimmedString(attributes.getValue(SPECIFICATION_VENDOR)); - if (null == specVendor) { - throw new ParseException(MISSING + SPECIFICATION_VENDOR, 0); - } - - final String specVersion - = getTrimmedString(attributes.getValue(SPECIFICATION_VERSION)); - if (null == specVersion) { - throw new ParseException(MISSING + SPECIFICATION_VERSION, 0); - } - - final String impTitle - = getTrimmedString(attributes.getValue(IMPLEMENTATION_TITLE)); - if (null == impTitle) { - throw new ParseException(MISSING + IMPLEMENTATION_TITLE, 0); - } - - final String impVersion - = getTrimmedString(attributes.getValue(IMPLEMENTATION_VERSION)); - if (null == impVersion) { - throw new ParseException(MISSING + IMPLEMENTATION_VERSION, 0); - } - - final String impVendor - = getTrimmedString(attributes.getValue(IMPLEMENTATION_VENDOR)); - if (null == impVendor) { - throw new ParseException(MISSING + IMPLEMENTATION_VENDOR, 0); - } - - return new Specification(name, specVersion, specVendor, - impTitle, impVersion, impVendor, - new String[]{section}); - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/AntResolver.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/AntResolver.java deleted file mode 100644 index 6284679f..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/AntResolver.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension.resolvers; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Ant; -import org.apache.tools.ant.taskdefs.optional.extension.Extension; -import org.apache.tools.ant.taskdefs.optional.extension.ExtensionResolver; - -/** - * Resolver that just returns s specified location. - * - */ -public class AntResolver implements ExtensionResolver { - private File antfile; - private File destfile; - private String target; - - /** - * Sets the ant file - * @param antfile the ant file to set - */ - public void setAntfile(final File antfile) { - this.antfile = antfile; - } - - /** - * Sets the destination file - * @param destfile the destination file - */ - public void setDestfile(final File destfile) { - this.destfile = destfile; - } - - /** - * Sets the target - * @param target the target - */ - public void setTarget(final String target) { - this.target = target; - } - - /** - * Returns the resolved file - * @param extension the extension - * @param project the project - * @return the file resolved - * @throws BuildException if the file cannot be resolved - */ - public File resolve(final Extension extension, - final Project project) throws BuildException { - validate(); - - final Ant ant = new Ant(); - ant.setProject(project); - ant.setInheritAll(false); - ant.setAntfile(antfile.getName()); - - try { - final File dir = - antfile.getParentFile().getCanonicalFile(); - ant.setDir(dir); - } catch (final IOException ioe) { - throw new BuildException(ioe.getMessage(), ioe); - } - - if (null != target) { - ant.setTarget(target); - } - - ant.execute(); - - return destfile; - } - - /* - * Validates URL - */ - private void validate() { - if (null == antfile) { - final String message = "Must specify Buildfile"; - throw new BuildException(message); - } - - if (null == destfile) { - final String message = "Must specify destination file"; - throw new BuildException(message); - } - } - - /** - * Returns a string representation - * @return the string representation - */ - public String toString() { - return "Ant[" + antfile + "==>" + destfile + "]"; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/LocationResolver.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/LocationResolver.java deleted file mode 100644 index e2fec022..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/LocationResolver.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension.resolvers; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.optional.extension.Extension; -import org.apache.tools.ant.taskdefs.optional.extension.ExtensionResolver; - -/** - * Resolver that just returns s specified location. - * - */ -public class LocationResolver implements ExtensionResolver { - private String location; - - /** - * Sets the location for this resolver - * @param location the location - */ - public void setLocation(final String location) { - this.location = location; - } - - /** - * Returns the resolved file - * @param extension the extension - * @param project the project - * @return the file resolved - * @throws BuildException if no location is set - */ - public File resolve(final Extension extension, - final Project project) throws BuildException { - if (null == location) { - final String message = "No location specified for resolver"; - throw new BuildException(message); - } - - return project.resolveFile(location); - } - /** - * Returns a string representation of the Location - * @return the string representation - */ - public String toString() { - return "Location[" + location + "]"; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/URLResolver.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/URLResolver.java deleted file mode 100644 index d693b899..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/extension/resolvers/URLResolver.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.extension.resolvers; - -import java.io.File; -import java.net.URL; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Get; -import org.apache.tools.ant.taskdefs.optional.extension.Extension; -import org.apache.tools.ant.taskdefs.optional.extension.ExtensionResolver; - -/** - * Resolver that just returns s specified location. - * - */ -public class URLResolver implements ExtensionResolver { - private File destfile; - private File destdir; - private URL url; - - /** - * Sets the URL - * @param url the url - */ - public void setUrl(final URL url) { - this.url = url; - } - - /** - * Sets the destination file - * @param destfile the destination file - */ - public void setDestfile(final File destfile) { - this.destfile = destfile; - } - - /** - * Sets the destination directory - * @param destdir the destination directory - */ - public void setDestdir(final File destdir) { - this.destdir = destdir; - } - - /** - * Returns the file resolved from URL and directory - * @param extension the extension - * @param project the project - * @return file the file resolved - * @throws BuildException if the URL is invalid - */ - public File resolve(final Extension extension, - final Project project) throws BuildException { - validate(); - - final File file = getDest(); - - final Get get = new Get(); - get.setProject(project); - get.setDest(file); - get.setSrc(url); - get.execute(); - - return file; - } - - /* - * Gets the destination file - */ - private File getDest() { - File result; - if (null != destfile) { - result = destfile; - } else { - final String file = url.getFile(); - String filename; - if (null == file || file.length() <= 1) { - filename = "default.file"; - } else { - int index = file.lastIndexOf('/'); - if (-1 == index) { - index = 0; - } - filename = file.substring(index); - } - result = new File(destdir, filename); - } - return result; - } - - /* - * Validates URL - */ - private void validate() { - if (null == url) { - final String message = "Must specify URL"; - throw new BuildException(message); - } - - if (null == destdir && null == destfile) { - final String message = "Must specify destination file or directory"; - throw new BuildException(message); - } else if (null != destdir && null != destfile) { - final String message = "Must not specify both destination file or directory"; - throw new BuildException(message); - } - } - - /** - * Returns a string representation of the URL - * @return the string representation - */ - public String toString() { - return "URL[" + url + "]"; - } -} |