Exemplo n.º 1
0
  private void scan(String pattern) {
    LOGGER.fine("Scanning " + pattern + " for hs_err_pid files");

    pattern = pattern.replace("%p", "*").replace("%%", "%");
    File f = new File(pattern).getAbsoluteFile();
    if (!pattern.contains("*")) scanFile(f);
    else { // GLOB
      File commonParent = f;
      while (commonParent != null && commonParent.getPath().contains("*")) {
        commonParent = commonParent.getParentFile();
      }
      if (commonParent == null) {
        LOGGER.warning("Failed to process " + f);
        return; // huh?
      }

      FileSet fs =
          Util.createFileSet(
              commonParent, f.getPath().substring(commonParent.getPath().length() + 1), null);
      DirectoryScanner ds = fs.getDirectoryScanner(new Project());
      for (String child : ds.getIncludedFiles()) {
        scanFile(new File(commonParent, child));
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Scans a directory for files matching the includes pattern.
   *
   * @param directory the directory to scan.
   * @param includes the includes pattern.
   * @param listener Hudson Build listener.
   * @return array of strings of paths for files that match the includes pattern in the directory.
   * @throws IOException
   */
  protected String[] scan(final File directory, final String includes, final BuildListener listener)
      throws IOException {
    String[] fileNames = new String[0];

    if (StringUtils.isNotBlank(includes)) {
      FileSet fs = null;

      try {
        fs = Util.createFileSet(directory, includes);

        DirectoryScanner ds = fs.getDirectoryScanner();
        fileNames = ds.getIncludedFiles();
      } catch (BuildException e) {
        e.printStackTrace(listener.getLogger());
        throw new IOException(e);
      }
    }

    if (LOGGER.isLoggable(Level.FINE)) {
      for (String fileName : fileNames) {
        LOGGER.log(Level.FINE, "Test result file found: " + fileName);
      }
    }

    return fileNames;
  }
Exemplo n.º 3
0
    @SuppressWarnings("unchecked")
    public List<IvyModuleInfo> call() throws Throwable {
      File ws = new File(workspace);
      FileSet ivyFiles = Util.createFileSet(ws, ivyFilePattern, ivyFileExcludePattern);
      final PrintStream logger = listener.getLogger();

      Ivy ivy = getIvy(logger);
      HashMap<ModuleDescriptor, String> moduleDescriptors = new HashMap<ModuleDescriptor, String>();
      for (String ivyFilePath : ivyFiles.getDirectoryScanner().getIncludedFiles()) {
        final File ivyFile = new File(ws, ivyFilePath);

        ModuleDescriptor module =
            (ModuleDescriptor)
                ivy.execute(
                    new IvyCallback() {
                      public Object doInIvyContext(Ivy ivy, IvyContext context) {
                        try {
                          return ModuleDescriptorParserRegistry.getInstance()
                              .parseDescriptor(
                                  ivy.getSettings(),
                                  ivyFile.toURI().toURL(),
                                  ivy.getSettings().doValidate());
                        } catch (MalformedURLException e) {
                          logger.println("The URL is malformed : " + ivyFile);
                          return null;
                        } catch (ParseException e) {
                          logger.println("Parsing error while reading the ivy file " + ivyFile);
                          return null;
                        } catch (IOException e) {
                          logger.println("I/O error while reading the ivy file " + ivyFile);
                          return null;
                        }
                      }
                    });
        moduleDescriptors.put(module, ivyFilePath.replace('\\', '/'));
      }

      List<IvyModuleInfo> infos = new ArrayList<IvyModuleInfo>();
      List<ModuleDescriptor> sortedModuleDescriptors =
          ivy.sortModuleDescriptors(moduleDescriptors.keySet(), SortOptions.DEFAULT);
      for (ModuleDescriptor moduleDescriptor : sortedModuleDescriptors) {
        infos.add(new IvyModuleInfo(moduleDescriptor, moduleDescriptors.get(moduleDescriptor)));
      }

      if (verbose) {
        for (IvyModuleInfo moduleInfo : infos) {
          logger.printf(
              "Discovered module %s at %s.\n",
              moduleInfo.displayName, moduleInfo.relativePathToDescriptor);
        }
      }

      return infos;
    }
Exemplo n.º 4
0
    @Override
    public Map<String, String> invoke(File basedir, VirtualChannel channel)
        throws IOException, InterruptedException {
      Map<String, String> r = new HashMap<String, String>();

      FileSet fileSet = Util.createFileSet(basedir, includes, excludes);
      fileSet.setDefaultexcludes(defaultExcludes);
      fileSet.setCaseSensitive(caseSensitive);

      for (String f : fileSet.getDirectoryScanner().getIncludedFiles()) {
        f = f.replace(File.separatorChar, '/');
        r.put(f, f);
      }
      return r;
    }
Exemplo n.º 5
0
    public List<List<Path>> invoke(File baseDir, VirtualChannel channel) throws IOException {
      FileSet fs = Util.createFileSet(baseDir, pattern);
      DirectoryScanner ds = fs.getDirectoryScanner();
      String[] files = ds.getIncludedFiles();

      if (files.length > 0) {
        List<List<Path>> r = new ArrayList<List<Path>>(files.length);
        for (String match : files) {
          List<Path> file = buildPathList(baseDir, new File(baseDir, match));
          r.add(file);
        }
        return r;
      }

      return null;
    }