Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Apache Ant Source Code Files
Apache Ant Source Code Files are inside the Apache Ant source package file like apache-ant-1.10.10-src.zip. Unzip the source package file and go to the "src/main" sub-directory, you will see source code files.
Here is the list of Java source code files of the Apache Ant 1.10.10 in \Users\fyicenter\apache-ant-1.10.10\src\main:
✍: FYIcenter.com
⏎ org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
/* * 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 * * https://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.io.OutputStream; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; 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="https://docs.oracle.com/javase/8/docs/technotes/guides/extensions/versioning.html"> * https://docs.oracle.com/javase/8/docs/technotes/guides/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 List<ExtensionSet> dependencies = new ArrayList<>(); /** * ExtensionAdapter objects representing optional * dependencies required by library. */ private final List<ExtensionSet> optionals = new ArrayList<>(); /** * Extra attributes the user specifies for main section * in manifest. */ private final List<ExtraAttribute> 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. */ @Override 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 List<Extension> 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 List<Extension> 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("%s is not a file.", destFile); } } /** * Add any extra attributes to the manifest. * * @param attributes the manifest section to write * attributes to */ private void appendExtraAttributes(final Attributes attributes) { for (ExtraAttribute attribute : extraAttributes) { 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 { try (OutputStream output = Files.newOutputStream(destFile.toPath())) { manifest.write(output); output.flush(); } } /** * 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 List<Extension> extensions) throws BuildException { final int size = extensions.size(); for (int i = 0; i < size; i++) { Extension.addExtension(extensions.get(i), listPrefix + i + "-", 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 libraries to list * @param listPrefix the prefix for all libraries * @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) { //add in something like //"Extension-List: javahelp java3d" attributes.put(extensionKey, IntStream.range(0, size) .mapToObj(i -> listPrefix + i).collect(Collectors.joining(" "))); } /** * 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 List<Extension> toExtensions(final List<ExtensionSet> extensionSets) throws BuildException { final Project prj = getProject(); return extensionSets.stream().map(xset -> xset.toExtensions(prj)) .flatMap(Stream::of).collect(Collectors.toList()); } }
⏎ org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java
Or download all of them as a single archive file:
File name: apache-ant-1.10.10-fyi.zip File size: 2392938 bytes Release date: 2021-04-17 Download
⇐ Download Apache Ant Source Package
2021-07-10, 110226👍, 0💬
Popular Posts:
JDK 11 jdk.xml.dom.jmod is the JMOD file for JDK 11 XML DOM module. JDK 11 XML DOM module compiled c...
The Jakarta-ORO Java classes are a set of text-processing Java classes that provide Perl5 compatible...
JasperReports, the world's most popular open source business intelligence and reporting engine and J...
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
JDK 11 jdk.internal.vm.ci.jmod is the JMOD file for JDK 11 Internal VM CI module. JDK 11 Internal VM...