Package org.apache.tools.ant.types

Examples of org.apache.tools.ant.types.ResourceCollection


                               getLocation());
    }

    // First analyze the exports resource collections
    for (Iterator it = exportsResourceCollections.iterator(); it.hasNext(); ) {
      final ResourceCollection rc = (ResourceCollection) it.next();

      for (Iterator rcIt = rc.iterator(); rcIt.hasNext();) {
        final Resource res = (Resource) rcIt.next();
        log("Exports resource: "+res, Project.MSG_DEBUG);
        analyze(res);
      }
    }// Scan done

    // Get the sub-set of the provided packages that are the exports set
    final Set providedExportSet = new TreeSet(bpInfo.getProvidedPackages());
    final Set manifestExportSet = getPredefinedExportSet();
    if (null!=manifestExportSet) {
      // An Export-Package header was given it shall contain
      // precisely the provided export set of Java packages.
      if (!manifestExportSet.equals(providedExportSet)) {
        // Found export package missmatch
        log("Provided package to export:  " +providedExportSet,
            Project.MSG_ERR);
        log("Given Export-Package header: " +manifestExportSet,
            Project.MSG_ERR);
        final StringBuffer msg = new StringBuffer();
        final TreeSet tmp = new TreeSet(manifestExportSet);
        tmp.removeAll(providedExportSet);
        if (0<tmp.size()) {
          msg.append("The following non-provided packages are present in the ")
            .append("Export-Package header: ")
            .append(tmp.toString())
            .append(". ");
        }
        tmp.clear();
        tmp.addAll(providedExportSet);
        tmp.removeAll(manifestExportSet);
        if (0<tmp.size()) {
          if (0<msg.length()) {
            msg.append("\n");
          }
          msg.append("The following packages are missing from ")
            .append("the given Export-Package header: ")
            .append(tmp.toString())
            .append(".");
        }
        tmp.clear();
        if (failOnExports) {
          log(msg.toString(), Project.MSG_ERR);
          throw new BuildException(msg.toString(), getLocation());
        } else {
          log(msg.toString(), Project.MSG_WARN);
        }
      }
    }
    log("Provided packages to export: " +providedExportSet,
        Project.MSG_VERBOSE);


    // Analyze the impls resource collections to find all provided
    // Java packages.
    for (Iterator it = implsResourceCollections.iterator(); it.hasNext(); ) {
      final ResourceCollection rc = (ResourceCollection) it.next();

      for (Iterator rcIt = rc.iterator(); rcIt.hasNext();) {
        final Resource res = (Resource) rcIt.next();
        log("Impl resource: "+res, Project.MSG_DEBUG);
        analyze(res);
      }
    }// Scan done
View Full Code Here


      throw new BuildException("No resource collections specified");
    }

    try {
      for (Iterator it = resourceCollections.iterator(); it.hasNext();) {
        final ResourceCollection rc = (ResourceCollection) it.next();

        // Ignore file sets with a non existing root dir.
        if (rc instanceof FileSet) {
          final FileSet fs = (FileSet) rc;
          final File fsRootDir = fs.getDir(task.getProject());
          if (!fsRootDir.exists()) {
            task.log("Skipping nested file set rooted at '" + fsRootDir
                + "' since that directory does not exist.", Project.MSG_WARN);
            continue;
          }
          try {
            if (fs.size()<1) {
              task.log("Skipping nested file set rooted at '" + fsRootDir
                  + "' since that file set is empty.", Project.MSG_VERBOSE);
              continue;
             
            }
          } catch (Exception e) {
            task.log("Skipping nested file set rooted at '" + fsRootDir
                + "' since size computation throws exception.", e, Project.MSG_VERBOSE);
            continue;
          }
        }

        for (Iterator rcIt = rc.iterator(); rcIt.hasNext();) {
          final Resource res = (Resource) rcIt.next();
          if (res.getName().endsWith(".jar")) {
            task.log("Adding bundle: " + res, Project.MSG_VERBOSE);
            final BundleArchive ba = new BundleArchive(task,
                                                       (FileResource) res, parseExportImport);
View Full Code Here

      int totalIgnored = 0;
      try {
        writer.setMergeFactor(mergeFactor);

        for (int i = 0; i < rcs.size(); i++) {
          ResourceCollection rc = rcs.elementAt(i);
          if (rc.isFilesystemOnly()) {
            Iterator resources = rc.iterator();
            while (resources.hasNext()) {
              Resource r = (Resource) resources.next();
              if (!r.isExists() || !(r instanceof FileResource)) {
                continue;
              }
View Full Code Here

     */
    public void execute() throws BuildException {
        File savedFile = file; // may be altered in validateAttributes
        File savedDestFile = destFile;
        File savedDestDir = destDir;
        ResourceCollection savedRc = null;
        if (file == null && destFile != null && rcs.size() == 1) {
            // will be removed in validateAttributes
            savedRc = (ResourceCollection) rcs.elementAt(0);
        }
        // make sure we don't have an illegal set of options
        validateAttributes();

        try {
            // deal with the single file
            copySingleFile();

            // deal with the ResourceCollections

            /* for historical and performance reasons we have to do
               things in a rather complex way.

               (1) Move is optimized to move directories if a fileset
               has been included completely, therefore FileSets need a
               special treatment.  This is also required to support
               the failOnError semantice (skip filesets with broken
               basedir but handle the remaining collections).

               (2) We carry around a few protected methods that work
               on basedirs and arrays of names.  To optimize stuff, all
               resources with the same basedir get collected in
               separate lists and then each list is handled in one go.
            */

            HashMap filesByBasedir = new HashMap();
            HashMap dirsByBasedir = new HashMap();
            HashSet baseDirs = new HashSet();
            ArrayList nonFileResources = new ArrayList();
            for (int i = 0; i < rcs.size(); i++) {
                ResourceCollection rc = (ResourceCollection) rcs.elementAt(i);

                // Step (1) - beware of the ZipFileSet
                if (rc instanceof FileSet && rc.isFilesystemOnly()) {
                    FileSet fs = (FileSet) rc;
                    DirectoryScanner ds = null;
                    try {
                        ds = fs.getDirectoryScanner(getProject());
                    } catch (BuildException e) {
                        if (failonerror
                            || !getMessage(e).endsWith(" not found.")) {
                            throw e;
                        } else {
                            log("Warning: " + getMessage(e), Project.MSG_ERR);
                            continue;
                        }
                    }
                    File fromDir = fs.getDir(getProject());

                    String[] srcFiles = ds.getIncludedFiles();
                    String[] srcDirs = ds.getIncludedDirectories();
                    if (!flatten && mapperElement == null
                        && ds.isEverythingIncluded() && !fs.hasPatterns()) {
                        completeDirMap.put(fromDir, destDir);
                    }
                    add(fromDir, srcFiles, filesByBasedir);
                    add(fromDir, srcDirs, dirsByBasedir);
                    baseDirs.add(fromDir);
                } else { // not a fileset or contains non-file resources

                    if (!rc.isFilesystemOnly() && !supportsNonFileResources()) {
                        throw new BuildException(
                                   "Only FileSystem resources are supported.");
                    }

                    Iterator resources = rc.iterator();
                    while (resources.hasNext()) {
                        Resource r = (Resource) resources.next();
                        if (!r.isExists()) {
                            continue;
                        }
View Full Code Here

        if (destFile != null && rcs.size() > 0) {
            if (rcs.size() > 1) {
                throw new BuildException(
                    "Cannot concatenate multiple files into a single file.");
            } else {
                ResourceCollection rc = (ResourceCollection) rcs.elementAt(0);
                if (!rc.isFilesystemOnly()) {
                    throw new BuildException("Only FileSystem resources are"
                                             + " supported when concatenating"
                                             + " files.");
                }
                if (rc.size() == 0) {
                    throw new BuildException(
                        "Cannot perform operation from directory to file.");
                } else if (rc.size() == 1) {
                    FileResource r = (FileResource) rc.iterator().next();
                    if (file == null) {
                        file = r.getFile();
                        rcs.removeElementAt(0);
                    } else {
                        throw new BuildException(
View Full Code Here

        validate();
        if (binary && destinationFile == null) {
            throw new BuildException(
                "destfile attribute is required for binary concatenation");
        }
        ResourceCollection c = getResources();
        if (isUpToDate(c)) {
            log(destinationFile + " is up-to-date.", Project.MSG_VERBOSE);
            return;
        }
        if (c.size() == 0) {
            return;
        }
        OutputStream out;
        if (destinationFile == null) {
            // Log using WARN so it displays in 'quiet' mode.
View Full Code Here

     * @since 1.7
     */
    private void addSourceFiles(Vector sf) {
        Iterator e = nestedSourceFiles.iterator();
        while (e.hasNext()) {
            ResourceCollection rc = (ResourceCollection) e.next();
            if (!rc.isFilesystemOnly()) {
                throw new BuildException("only file system based resources are"
                                         + " supported by javadoc");
            }
            if (rc instanceof FileSet) {
                FileSet fs = (FileSet) rc;
                if (!fs.hasPatterns() && !fs.hasSelectors()) {
                    FileSet fs2 = (FileSet) fs.clone();
                    fs2.createInclude().setName("**/*.java");
                    if (includeNoSourcePackages) {
                        fs2.createInclude().setName("**/package.html");
                    }
                    rc = fs2;
                }
            }
            Iterator iter = rc.iterator();
            while (iter.hasNext()) {
                sf.addElement(new SourceFile(((FileResource) iter.next())
                                             .getFile()));
            }
        }
View Full Code Here

    /**
     * Sort the contained elements.
     * @return a Collection of Resources.
     */
    protected synchronized Collection getCollection() {
        ResourceCollection rc = getResourceCollection();
        if (rc.size() == 0) {
            return Collections.EMPTY_SET;
        }
        if (tokenizer == null) {
            tokenizer = new LineTokenizer();
        }
View Full Code Here

    /**
     * Sort the contained elements.
     * @return a Collection of Resources.
     */
    protected synchronized Collection getCollection() {
        ResourceCollection rc = getResourceCollection();
        Iterator iter = rc.iterator();
        if (!(iter.hasNext())) {
            return Collections.EMPTY_SET;
        }
        SortedBag b = new SortedBag(comp);
        while (iter.hasNext()) {
View Full Code Here

     * @since 1.7
     */
    private void addSourceFiles(Vector<SourceFile> sf) {
        Iterator<ResourceCollection> e = nestedSourceFiles.iterator();
        while (e.hasNext()) {
            ResourceCollection rc = e.next();
            if (!rc.isFilesystemOnly()) {
                throw new BuildException("only file system based resources are"
                                         + " supported by javadoc");
            }
            if (rc instanceof FileSet) {
                FileSet fs = (FileSet) rc;
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.types.ResourceCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.