org.apache.tools.ant.DirectoryScanner Java Examples

The following examples show how to use org.apache.tools.ant.DirectoryScanner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSummaryCreatorTask.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the list of input files ({@link java.io.File} objects) to process.
 * Note that this does not check that the file is a valid and useful XML file.
 * 
 * @return The input files
 */
private List getInputFiles()
{
	ArrayList result = new ArrayList();

    for (Iterator it = _fileSets.iterator(); it.hasNext();)
    {
        FileSet          fileSet    = (FileSet)it.next();
        File             fileSetDir = fileSet.getDir(getProject());
        DirectoryScanner scanner    = fileSet.getDirectoryScanner(getProject());
        String[]         files      = scanner.getIncludedFiles();

        for (int idx = 0; (files != null) && (idx < files.length); idx++)
        {
        	File file = new File(fileSetDir, files[idx]);

            if (file.isFile() && file.canRead())
            {
            	result.add(file);
            }
        }
    }
    return result;
}
 
Example #2
Source File: IvyCacheFilesetTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimple() {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
    fileset.setSetid("simple-setid");
    fileset.execute();
    Object ref = project.getReference("simple-setid");
    assertNotNull(ref);
    assertTrue(ref instanceof FileSet);
    FileSet fs = (FileSet) ref;
    DirectoryScanner directoryScanner = fs.getDirectoryScanner(project);
    assertEquals(1, directoryScanner.getIncludedFiles().length);
    assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar")
            .getAbsolutePath(),
        new File(directoryScanner.getBasedir(), directoryScanner.getIncludedFiles()[0])
                .getAbsolutePath());
}
 
Example #3
Source File: ObfuscatorTask.java    From yGuard with MIT License 6 votes vote down vote up
public void createEntries(Collection srcJars) throws IOException
{
  entries = new HashSet();
  for(Iterator iter = srcJars.iterator(); iter.hasNext();)
  {
    File file = (File) iter.next();
    setSrc(file);

    DirectoryScanner scanner = getDirectoryScanner(getProject());
    String[] includedFiles  = ZipScannerTool.getMatches(this, scanner);

    for(int i = 0; i < includedFiles.length; i++)
    {
      entries.add(includedFiles[i]);
    }
  }
}
 
Example #4
Source File: ApexCli.java    From Bats with Apache License 2.0 6 votes vote down vote up
private static String[] expandFileNames(String fileName) throws IOException
{
  // TODO: need to work with other users
  if (fileName.matches("^[a-zA-Z]+:.*")) {
    // it's a URL
    return new String[]{fileName};
  }
  if (fileName.startsWith("~" + File.separator)) {
    fileName = System.getProperty("user.home") + fileName.substring(1);
  }
  fileName = new File(fileName).getCanonicalPath();
  LOG.debug("Canonical path: {}", fileName);
  DirectoryScanner scanner = new DirectoryScanner();
  scanner.setIncludes(new String[]{fileName});
  scanner.scan();
  return scanner.getIncludedFiles();
}
 
Example #5
Source File: JUnitParser.java    From junit-plugin with MIT License 6 votes vote down vote up
public TestResult invoke(File ws, VirtualChannel channel) throws IOException {
    final long nowSlave = System.currentTimeMillis();

    FileSet fs = Util.createFileSet(ws, testResults);
    DirectoryScanner ds = fs.getDirectoryScanner();
    TestResult result = null;

    String[] files = ds.getIncludedFiles();
    if (files.length > 0) {
        result = new TestResult(buildTime + (nowSlave - nowMaster), ds, keepLongStdio, pipelineTestDetails);
        result.tally();
    } else {
        if (this.allowEmptyResults) {
            result = new TestResult();
        } else {
            // no test result. Most likely a configuration
            // error or fatal problem
            throw new AbortException(Messages.JUnitResultArchiver_NoTestReportFound());
        }
    }
    return result;
}
 
Example #6
Source File: ApexCli.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
private static String[] expandFileNames(String fileName) throws IOException
{
  // TODO: need to work with other users
  if (fileName.matches("^[a-zA-Z]+:.*")) {
    // it's a URL
    return new String[]{fileName};
  }
  if (fileName.startsWith("~" + File.separator)) {
    fileName = System.getProperty("user.home") + fileName.substring(1);
  }
  fileName = new File(fileName).getCanonicalPath();
  LOG.debug("Canonical path: {}", fileName);
  DirectoryScanner scanner = new DirectoryScanner();
  scanner.setIncludes(new String[]{fileName});
  scanner.scan();
  return scanner.getIncludedFiles();
}
 
Example #7
Source File: OperatorDiscoveryTest.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
public static String[] getClassFileInClasspath()
{
  String classpath = System.getProperty("java.class.path");
  String[] paths = classpath.split(":");
  List<String> fnames = new LinkedList<>();
  for (String cp : paths) {
    File f = new File(cp);
    if (!f.isDirectory()) {
      continue;
    }
    DirectoryScanner ds = new DirectoryScanner();
    ds.setBasedir(f);
    ds.setIncludes(new String[]{"**\\*.class"});
    ds.scan();
    for (String name : ds.getIncludedFiles()) {
      fnames.add(new File(f, name).getAbsolutePath());
    }

  }
  return fnames.toArray(new String[]{});
}
 
Example #8
Source File: BasicStyleCheckerTask.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws BuildException {
    BasicStyleCheckerEngine engine = new BasicStyleCheckerEngine();
    
    try {
        for (FileSet fileset: filesets) {
            final DirectoryScanner scanner =
                    fileset.getDirectoryScanner(getProject());
            
            for (String filename: scanner.getIncludedFiles()) {
                final File file =
                        new File(fileset.getDir(getProject()), filename);
                
                System.out.println(file.getCanonicalPath());
                engine.check(file);
            }
        }
    } catch (IOException e) {
        throw new BuildException(e);
    }
}
 
Example #9
Source File: MapUpdater.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ants execute method.
 */
@Override
public void execute() {
	try {
		for (final FileSet fileset : filesets) {
			final DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
			final String[] includedFiles = ds.getIncludedFiles();
			for (final String filename : includedFiles) {
				System.out.println(ds.getBasedir().getAbsolutePath()
						+ File.separator + filename);
				convert(ds.getBasedir().getAbsolutePath() + File.separator
						+ filename);
			}
		}
	} catch (final Exception e) {
		throw new BuildException(e);
	}
}
 
Example #10
Source File: UpdateSigner.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ants execute method.
 */
@Override
public void execute() {
	try {
		for (final FileSet fileset : filesets) {
			final DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
			final String[] includedFiles = ds.getIncludedFiles();
			for (final String filename : includedFiles) {
				String signature = sign(ds.getBasedir().getAbsolutePath()
						+ File.separator + filename);
				System.out.println("file-signature." + filename + "=" + signature);
			}
		}
	} catch (final Exception e) {
		throw new BuildException(e);
	}
}
 
Example #11
Source File: MapRenderer.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ants execute method.
 */
@Override
public void execute() {
	try {
		for (final FileSet fileset : filesets) {
			final DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
			final String[] includedFiles = ds.getIncludedFiles();
			for (final String filename : includedFiles) {
				System.out.println(ds.getBasedir().getAbsolutePath() + File.separator + filename);
				convert(ds.getBasedir().getAbsolutePath() + File.separator + filename);
			}
		}
	} catch (final Exception e) {
		throw new BuildException(e);
	}
}
 
Example #12
Source File: BasicInstrumentationTask.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void collectClassNames() {
	logger.info( "collecting class names for extended instrumentation determination" );
	Project project = getProject();
	Iterator filesets = filesets();
	while ( filesets.hasNext() ) {
		FileSet fs = ( FileSet ) filesets.next();
		DirectoryScanner ds = fs.getDirectoryScanner( project );
		String[] includedFiles = ds.getIncludedFiles();
		File d = fs.getDir( project );
		for ( int i = 0; i < includedFiles.length; ++i ) {
			File file = new File( d, includedFiles[i] );
			try {
				collectClassNames( file );
			}
			catch ( Exception e ) {
				throw new BuildException( e );
			}
		}
	}
	logger.info( classNames.size() + " class(es) being checked" );
}
 
Example #13
Source File: BasicInstrumentationTask.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void execute() throws BuildException {
	if ( isExtended() ) {
		collectClassNames();
	}
	logger.info( "starting instrumentation" );
	Project project = getProject();
	Iterator filesets = filesets();
	while ( filesets.hasNext() ) {
		FileSet fs = ( FileSet ) filesets.next();
		DirectoryScanner ds = fs.getDirectoryScanner( project );
		String[] includedFiles = ds.getIncludedFiles();
		File d = fs.getDir( project );
		for ( int i = 0; i < includedFiles.length; ++i ) {
			File file = new File( d, includedFiles[i] );
			try {
				processFile( file );
			}
			catch ( Exception e ) {
				throw new BuildException( e );
			}
		}
	}
}
 
Example #14
Source File: MakeJNLP.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void processIndirectFiles(Writer fileWriter, String dashcnb) throws IOException, BuildException {
    if (indirectFiles == null) {
        return;
    }
    DirectoryScanner scan = indirectFiles.getDirectoryScanner(getProject());
    Map<String,File> entries = new LinkedHashMap<>();
    for (String f : scan.getIncludedFiles()) {
        entries.put(f.replace(File.separatorChar, '/'), new File(scan.getBasedir(), f));
    }
    if (entries.isEmpty()) {
        return;
    }
    File ext = new File(new File(targetFile, dashcnb), "extra-files.jar");
    Zip jartask = (Zip) getProject().createTask("jar");
    jartask.setDestFile(ext);
    for (Map.Entry<String,File> entry : entries.entrySet()) {
        ZipFileSet zfs = new ZipFileSet();
        zfs.setFile(entry.getValue());
        zfs.setFullpath("META-INF/files/" + entry.getKey());
        jartask.addZipfileset(zfs);
    }
    jartask.execute();
    fileWriter.write(constructJarHref(ext, dashcnb));
    signOrCopy(ext, null);
}
 
Example #15
Source File: AntFile.java    From antiplag with Apache License 2.0 6 votes vote down vote up
public static String[] scanFiles(File f,String[] filter){
	String[] includeFiles = null;
	try {
		DirectoryScanner ds=new DirectoryScanner(); 
		
		ds.setBasedir(f); 
		ds.setIncludes(filter);  //**/*.java
		ds.scan(); 
		if(ds.getIncludedFilesCount()>0) { 	 
		 includeFiles=ds.getIncludedFiles(); 
		}
	} catch (IllegalStateException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return includeFiles;
	 
}
 
Example #16
Source File: ZipStepExecution.java    From pipeline-utility-steps-plugin with MIT License 6 votes vote down vote up
@Override
public Integer invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException {
    String canonicalZip = zipFile.getRemote();
    if (overwrite && !Files.deleteIfExists(Paths.get(canonicalZip))) {
        throw new IOException("Failed to delete " + canonicalZip);
    }

    Archiver archiver = ArchiverFactory.ZIP.create(zipFile.write());
    FileSet fs = Util.createFileSet(dir, glob);
    DirectoryScanner scanner = fs.getDirectoryScanner(new org.apache.tools.ant.Project());
    try {
        for (String path : scanner.getIncludedFiles()) {
            File toArchive = new File(dir, path).getCanonicalFile();
            if (!toArchive.getPath().equals(canonicalZip)) {
                archiver.visit(toArchive, path);
            }
        }
    } finally {
        archiver.close();
    }
    return archiver.countEntries();
}
 
Example #17
Source File: RccTask.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Invoke the Hadoop record compiler on each record definition file
 */
@Override
public void execute() throws BuildException {
  if (src == null && filesets.size()==0) {
    throw new BuildException("There must be a file attribute or a fileset child element");
  }
  if (src != null) {
    doCompile(src);
  }
  Project myProject = getProject();
  for (int i = 0; i < filesets.size(); i++) {
    FileSet fs = filesets.get(i);
    DirectoryScanner ds = fs.getDirectoryScanner(myProject);
    File dir = fs.getDir(myProject);
    String[] srcs = ds.getIncludedFiles();
    for (int j = 0; j < srcs.length; j++) {
      doCompile(new File(dir, srcs[j]));
    }
  }
}
 
Example #18
Source File: TestSummaryCreatorTask.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the list of input files ({@link java.io.File} objects) to process.
 * Note that this does not check that the file is a valid and useful XML file.
 * 
 * @return The input files
 */
private List getInputFiles()
{
	ArrayList result = new ArrayList();

    for (Iterator it = _fileSets.iterator(); it.hasNext();)
    {
        FileSet          fileSet    = (FileSet)it.next();
        File             fileSetDir = fileSet.getDir(getProject());
        DirectoryScanner scanner    = fileSet.getDirectoryScanner(getProject());
        String[]         files      = scanner.getIncludedFiles();

        for (int idx = 0; (files != null) && (idx < files.length); idx++)
        {
        	File file = new File(fileSetDir, files[idx]);

            if (file.isFile() && file.canRead())
            {
            	result.add(file);
            }
        }
    }
    return result;
}
 
Example #19
Source File: RccTask.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Invoke the Hadoop record compiler on each record definition file
 */
@Override
public void execute() throws BuildException {
  if (src == null && filesets.size()==0) {
    throw new BuildException("There must be a file attribute or a fileset child element");
  }
  if (src != null) {
    doCompile(src);
  }
  Project myProject = getProject();
  for (int i = 0; i < filesets.size(); i++) {
    FileSet fs = filesets.get(i);
    DirectoryScanner ds = fs.getDirectoryScanner(myProject);
    File dir = fs.getDir(myProject);
    String[] srcs = ds.getIncludedFiles();
    for (int j = 0; j < srcs.length; j++) {
      doCompile(new File(dir, srcs[j]));
    }
  }
}
 
Example #20
Source File: StramAppLauncher.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
private void processLibJars(String libjars, Set<URL> clUrls) throws Exception
{
  for (String libjar : libjars.split(",")) {
    // if hadoop file system, copy from hadoop file system to local
    URI uri = new URI(libjar);
    String scheme = uri.getScheme();
    if (scheme == null) {
      // expand wildcards
      DirectoryScanner scanner = new DirectoryScanner();
      scanner.setIncludes(new String[]{libjar});
      scanner.scan();
      String[] files = scanner.getIncludedFiles();
      for (String file : files) {
        clUrls.add(new URL("file:" + file));
      }
    } else if (scheme.equals("file")) {
      clUrls.add(new URL(libjar));
    } else {
      if (fs != null) {
        Path path = new Path(libjar);
        File dependencyJarsDir = new File(StramClientUtils.getUserDTDirectory(), "dependencyJars");
        dependencyJarsDir.mkdirs();
        File localJarFile = new File(dependencyJarsDir, path.getName());
        fs.copyToLocalFile(path, new Path(localJarFile.getAbsolutePath()));
        clUrls.add(new URL("file:" + localJarFile.getAbsolutePath()));
      } else {
        throw new NotImplementedException("Jar file needs to be from Hadoop File System also in order for the dependency jars to be in Hadoop File System");
      }
    }
  }
}
 
Example #21
Source File: PatternSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Spec<FileTreeElement> getAsExcludeSpec() {
    Collection<String> allExcludes = Sets.newLinkedHashSet(excludes);
    Collections.addAll(allExcludes, DirectoryScanner.getDefaultExcludes());

    List<Spec<FileTreeElement>> matchers = Lists.newArrayList();
    for (String exclude : allExcludes) {
        Spec<RelativePath> patternMatcher = PatternMatcherFactory.getPatternMatcher(false, caseSensitive, exclude);
        matchers.add(new RelativePathSpec(patternMatcher));
    }

    matchers.addAll(excludeSpecs);
    return new OrSpec<FileTreeElement>(matchers);
}
 
Example #22
Source File: ApexCli.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
private static String expandFileName(String fileName, boolean expandWildCard) throws IOException
{
  if (fileName.matches("^[a-zA-Z]+:.*")) {
    // it's a URL
    return fileName;
  }

  // TODO: need to work with other users' home directory
  if (fileName.startsWith("~" + File.separator)) {
    fileName = System.getProperty("user.home") + fileName.substring(1);
  }
  fileName = new File(fileName).getCanonicalPath();
  //LOG.debug("Canonical path: {}", fileName);
  if (expandWildCard) {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setIncludes(new String[]{fileName});
    scanner.scan();
    String[] files = scanner.getIncludedFiles();

    if (files.length == 0) {
      throw new CliException(fileName + " does not match any file");
    } else if (files.length > 1) {
      throw new CliException(fileName + " matches more than one file");
    }
    return files[0];
  } else {
    return fileName;
  }
}
 
Example #23
Source File: AbstractProcessTask.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
protected Collection getFiles() {
    Map fileMap = new HashMap();
    Project p = getProject();
    for (int i = 0; i < filesets.size(); i++) {
        FileSet fs = (FileSet)filesets.elementAt(i);
        DirectoryScanner ds = fs.getDirectoryScanner(p);
        String[] srcFiles = ds.getIncludedFiles();
        File dir = fs.getDir(p);
        for (int j = 0; j < srcFiles.length; j++) {
             File src = new File(dir, srcFiles[j]);
             fileMap.put(src.getAbsolutePath(), src);
        }
    }
    return fileMap.values();
}
 
Example #24
Source File: IvyCacheFilesetTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithoutPreviousResolveAndNonDefaultCache() {
    File cache2 = new File("build/cache2");
    cache2.mkdirs();

    try {
        project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
        fileset.setSetid("simple-setid");
        System.setProperty("ivy.cache.dir", cache2.getAbsolutePath());
        fileset.execute();
        Object ref = project.getReference("simple-setid");
        assertNotNull(ref);
        assertTrue(ref instanceof FileSet);
        FileSet fs = (FileSet) ref;
        DirectoryScanner directoryScanner = fs.getDirectoryScanner(project);
        assertEquals(1, directoryScanner.getIncludedFiles().length);
        assertEquals(
            getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", cache2)
                    .getAbsolutePath(), new File(directoryScanner.getBasedir(),
                    directoryScanner.getIncludedFiles()[0]).getAbsolutePath());
    } finally {
        Delete del = new Delete();
        del.setProject(new Project());
        del.setDir(cache2);
        del.execute();
    }
}
 
Example #25
Source File: Helper.java    From bootstraped-multi-test-results-report with MIT License 5 votes vote down vote up
public static String[] findFiles(File targetDirectory, String fileIncludePattern, String fileExcludePattern,
    final String DEFAULT_FILE_INCLUDE_PATTERN) {
    DirectoryScanner scanner = new DirectoryScanner();
    if (fileIncludePattern == null || fileIncludePattern.isEmpty()) {
        scanner.setIncludes(new String[] {DEFAULT_FILE_INCLUDE_PATTERN});
    } else {
        scanner.setIncludes(new String[] {fileIncludePattern});
    }
    if (fileExcludePattern != null) {
        scanner.setExcludes(new String[] {fileExcludePattern});
    }
    scanner.setBasedir(targetDirectory);
    scanner.scan();
    return scanner.getIncludedFiles();
}
 
Example #26
Source File: Txt2Html.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Perform the conversion
 *
 * @throws BuildException if an error occurs during execution of
 *    this task.
 */
@Override
public void execute()
    throws BuildException
{
    int count = 0;

    // Step through each file and convert.
    Iterator<FileSet> iter = filesets.iterator();
    while( iter.hasNext() ) {
        FileSet fs = iter.next();
        DirectoryScanner ds = fs.getDirectoryScanner(getProject());
        File basedir = ds.getBasedir();
        String[] files = ds.getIncludedFiles();
        for( int i = 0; i < files.length; i++ ) {
            File from = new File( basedir, files[i] );
            File to = new File( todir, files[i] + ".html" );
            if( !to.exists() ||
                (from.lastModified() > to.lastModified()) )
            {
                log( "Converting file '" + from.getAbsolutePath() +
                    "' to '" + to.getAbsolutePath(), Project.MSG_VERBOSE );
                try {
                    convert( from, to );
                }
                catch( IOException e ) {
                    throw new BuildException( "Could not convert '" +
                        from.getAbsolutePath() + "' to '" +
                        to.getAbsolutePath() + "'", e );
                }
                count++;
            }
        }
        if( count > 0 ) {
            log( "Converted " + count + " file" + (count > 1 ? "s" : "") +
                " to " + todir.getAbsolutePath() );
        }
    }
}
 
Example #27
Source File: EtlExecuteTask.java    From scriptella-etl with Apache License 2.0 5 votes vote down vote up
public void execute() throws BuildException {
    List<File> files = new ArrayList<File>();

    try {
        if (filesets.isEmpty()) { //if no files - use file default name
            files.add(launcher.resolveFile(getProject().getBaseDir(), null));
        } else {
            for (FileSet fs : filesets) {
                DirectoryScanner ds = fs.getDirectoryScanner(getProject());
                File srcDir = fs.getDir(getProject());

                String srcFiles[] = ds.getIncludedFiles();

                for (String fName : srcFiles) {
                    File file = launcher.resolveFile(srcDir, fName);
                    files.add(file);
                }
            }
        }
    } catch (FileNotFoundException e) {
        throw new BuildException(e.getMessage(), e);
    }

    if (fork) {
        fork(files);
    } else {
        execute(files);
    }
}
 
Example #28
Source File: MergeXmlFiles.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void execute() throws BuildException {
    try {
        System.out.println("Merging xml files in " + destFile);
        DirectoryScanner directoryScanner = filesets.get(0).getDirectoryScanner();
        File basedir = directoryScanner.getBasedir();
        String[] includedFiles = directoryScanner.getIncludedFiles();
        Document merge = merge(basedir, includedFiles);
        print(merge, destFile);
        System.out.println("Merging done!");
    } catch (Exception e) {
        e.printStackTrace();
        throw new BuildException(e);
    }
}
 
Example #29
Source File: Txt2Html.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Perform the conversion
 *
 * @throws BuildException if an error occurs during execution of
 *    this task.
 */
@Override
public void execute()
    throws BuildException
{
    int count = 0;

    // Step through each file and convert.
    for (FileSet fs : filesets) {
        DirectoryScanner ds = fs.getDirectoryScanner(getProject());
        File basedir = ds.getBasedir();
        String[] files = ds.getIncludedFiles();
        for( int i = 0; i < files.length; i++ ) {
            File from = new File( basedir, files[i] );
            File to = new File( todir, files[i] + ".html" );
            if( !to.exists() ||
                (from.lastModified() > to.lastModified()) )
            {
                log( "Converting file '" + from.getAbsolutePath() +
                    "' to '" + to.getAbsolutePath(), Project.MSG_VERBOSE );
                try {
                    convert( from, to );
                }
                catch( IOException e ) {
                    throw new BuildException( "Could not convert '" +
                        from.getAbsolutePath() + "' to '" +
                        to.getAbsolutePath() + "'", e );
                }
                count++;
            }
        }
        if( count > 0 ) {
            log( "Converted " + count + " file" + (count > 1 ? "s" : "") +
                " to " + todir.getAbsolutePath() );
        }
    }
}
 
Example #30
Source File: IvyCacheFilesetTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testEmptyConf() {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-108.xml");
    fileset.setSetid("emptyconf-setid");
    fileset.setConf("empty");
    fileset.execute();
    Object ref = project.getReference("emptyconf-setid");
    assertNotNull(ref);
    assertTrue(ref instanceof FileSet);
    FileSet fs = (FileSet) ref;
    DirectoryScanner directoryScanner = fs.getDirectoryScanner(project);
    directoryScanner.scan();
    assertEquals(0, directoryScanner.getIncludedFiles().length);
}