예제 #1
0
  /** Scans the source directories looking for source files to be decompiled. */
  protected void scanSrc() throws BuildException {
    for (@SuppressWarnings("unchecked") Iterator<Resource> it = src.iterator(); it.hasNext(); ) {
      Resource resource = it.next();
      FileResource fileResource = resource instanceof FileResource ? (FileResource) resource : null;
      if (fileResource != null) {
        File file = fileResource.getFile();
        if (file.isDirectory()) {
          DirectoryScanner ds = getDirectoryScanner(file);
          String[] files = ds.getIncludedFiles();

          scanDir(file, destdir != null ? destdir : file, files);
        } else {
          String[] files = new String[] {fileResource.getName()};

          scanDir(
              fileResource.getBaseDir(),
              destdir != null ? destdir : fileResource.getBaseDir(),
              files);
        }
      }
      //			else
      //			{
      //				//FIXME what to do?
      //			}
    }
  }
예제 #2
0
 /**
  * Implementation of ResourceSelector.isSelected().
  *
  * @param resource The resource to check
  * @return whether the resource is selected
  * @see ResourceSelector#isSelected(Resource)
  */
 public boolean isSelected(Resource resource) {
   if (resource.isFilesystemOnly()) {
     // We have a 'resourced' file, so reconvert it and use
     // the 'old' implementation.
     FileResource fileResource = (FileResource) resource;
     File file = fileResource.getFile();
     String filename = fileResource.getName();
     File basedir = fileResource.getBaseDir();
     return isSelected(basedir, filename, file);
   } else {
     try {
       // How to handle non-file-Resources? I copy temporarily the
       // resource to a file and use the file-implementation.
       FileUtils fu = FileUtils.getFileUtils();
       File tmpFile = fu.createTempFile("modified-", ".tmp", null, true, false);
       Resource tmpResource = new FileResource(tmpFile);
       ResourceUtils.copyResource(resource, tmpResource);
       boolean isSelected =
           isSelected(tmpFile.getParentFile(), tmpFile.getName(), resource.toLongString());
       tmpFile.delete();
       return isSelected;
     } catch (UnsupportedOperationException uoe) {
       log(
           "The resource '"
               + resource.getName()
               + "' does not provide an InputStream, so it is not checked. "
               + "Akkording to 'selres' attribute value it is "
               + ((selectResourcesWithoutInputStream) ? "" : " not")
               + "selected.",
           Project.MSG_INFO);
       return selectResourcesWithoutInputStream;
     } catch (Exception e) {
       throw new BuildException(e);
     }
   }
 }