本文整理匯總了Java中org.apache.tools.ant.DirectoryScanner.getIncludedDirectories方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryScanner.getIncludedDirectories方法的具體用法?Java DirectoryScanner.getIncludedDirectories怎麽用?Java DirectoryScanner.getIncludedDirectories使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tools.ant.DirectoryScanner
的用法示例。
在下文中一共展示了DirectoryScanner.getIncludedDirectories方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collect
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Collects all files from the supplied FileSet.
*
* @param receiver The Collection to receive the files (and implied directories). Not <code>null</code>.
* @param unmanaged The Collection to receive unmanaged directories. Not <code>null</code>.
* @param fileset The FileSet which has to be traversed. Not <code>null</code>.
*/
private void collect( List<File> receiver, List<File> unmanaged, FileSet fileset ) {
DirectoryScanner scanner = fileset.getDirectoryScanner( getProject() );
File dir = fileset.getDir( getProject() );
if( incfiledirs ) {
// we're including directories which are implied by the FileSet
String[] dirs = scanner.getIncludedDirectories();
for( String includeddir : dirs ) {
File directory = new File( dir, includeddir );
collectUnmanaged( unmanaged, dir, directory, false );
receiver.add( directory );
}
}
String[] files = scanner.getIncludedFiles();
for( String includedfile : files ) {
File file = new File( dir, includedfile );
collectUnmanaged( unmanaged, dir, file.getParentFile(), false );
receiver.add( file );
}
}
示例2: removeTestClasses
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Remove as classes de teste do sistema, para que elas nao entrem na
* analise. Todos os diretorios cujo nome comeca com 'test' (test*) serão
* excluídos.
*/
public void removeTestClasses() {
System.out.println("Deleting test folders");
DirectoryScanner scanner = new DirectoryScanner();
String[] includes = { "**/test*" };
scanner.setIncludes(includes);
scanner.setBasedir(src_path);
scanner.setCaseSensitive(false);
scanner.scan();
String[] included_dirs = scanner.getIncludedDirectories();
for (String test_dir : included_dirs) {
File dirToDelete = new File(src_path, test_dir);
if (dirToDelete.exists())
FileUtils.deleteRecursive(dirToDelete);
}
}
示例3: iterator
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public Iterator<Resource> iterator() {
final DirectoryScanner ds = getDirectoryScanner(getProject());
String[] names = type == SetType.file
? ds.getIncludedFiles()
: ds.getIncludedDirectories();
if (type == SetType.both) {
final String[] files = ds.getIncludedFiles();
final String[] merged = new String[names.length + files.length];
System.arraycopy(names, 0, merged, 0, names.length);
System.arraycopy(files, 0, merged, names.length, files.length);
names = merged;
}
return new FileResourceIterator(getProject(), getDir(getProject()),
names);
}
示例4: testGetWithSelector
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Test
public void testGetWithSelector() {
buildRule.executeTarget("ftp-get-with-selector");
assertContains("selectors are not supported in remote filesets", buildRule.getLog());
FileSet fsDestination = (FileSet) buildRule.getProject().getReference("fileset-destination-without-selector");
DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(buildRule.getProject());
dsDestination.scan();
String[] sortedDestinationDirectories = dsDestination.getIncludedDirectories();
String[] sortedDestinationFiles = dsDestination.getIncludedFiles();
for (int counter = 0; counter < sortedDestinationDirectories.length; counter++) {
sortedDestinationDirectories[counter] =
sortedDestinationDirectories[counter].replace(File.separatorChar, '/');
}
for (int counter = 0; counter < sortedDestinationFiles.length; counter++) {
sortedDestinationFiles[counter] =
sortedDestinationFiles[counter].replace(File.separatorChar, '/');
}
FileSet fsSource = (FileSet) buildRule.getProject().getReference("fileset-source-without-selector");
DirectoryScanner dsSource = fsSource.getDirectoryScanner(buildRule.getProject());
dsSource.scan();
compareFiles(dsSource, sortedDestinationFiles, sortedDestinationDirectories);
}
示例5: compareFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private void compareFiles(DirectoryScanner ds, String[] expectedFiles,
String[] expectedDirectories) {
String[] includedFiles = ds.getIncludedFiles();
String[] includedDirectories = ds.getIncludedDirectories();
assertEquals("file present: ", expectedFiles.length,
includedFiles.length);
assertEquals("directories present: ", expectedDirectories.length,
includedDirectories.length);
for (int counter = 0; counter < includedFiles.length; counter++) {
includedFiles[counter] = includedFiles[counter].replace(File.separatorChar, '/');
}
Arrays.sort(includedFiles);
for (int counter = 0; counter < includedDirectories.length; counter++) {
includedDirectories[counter] = includedDirectories[counter]
.replace(File.separatorChar, '/');
}
Arrays.sort(includedDirectories);
for (int counter = 0; counter < includedFiles.length; counter++) {
assertEquals(expectedFiles[counter], includedFiles[counter]);
}
for (int counter = 0; counter < includedDirectories.length; counter++) {
assertEquals(expectedDirectories[counter], includedDirectories[counter]);
counter++;
}
}
示例6: determineRequiredDirectories
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private Iterator determineRequiredDirectories(DirectoryScanner scanner) {
Set result = new HashSet();
// determine all directories that contain included files
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
String file = asDavPath(files[i]);
int slashPos = file.lastIndexOf('/');
if (slashPos != -1) {
result.add(file.substring(0, slashPos));
}
}
// determine all included directories
String[] dirs = scanner.getIncludedDirectories();
for(int i = 0; i < dirs.length; i++) {
result.add(asDavPath(dirs[i]));
}
return result.iterator();
}
示例7: getUserModuleLibFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* 獲取用戶模塊加載文件/目錄(集合)
*
* @return 用戶模塊加載文件/目錄(集合)
*/
public synchronized File[] getUserModuleLibFiles() {
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setIncludes(getUserModuleLibPaths());
scanner.setCaseSensitive(false);
scanner.scan();
final String[] filePaths = scanner.getIncludedDirectories();
final File[] files = new File[filePaths.length];
for (int index = 0; index < filePaths.length; index++) {
files[index] = new File(filePaths[index]);
}
return GET_USER_MODULE_LIB_FILES_CACHE = files;
}
示例8: grabResources
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Fetch all included and not excluded resources from the sets.
*
* <p>Included directories will precede included files.</p>
* @param filesets an array of filesets
* @return the resources included
* @since Ant 1.5.2
*/
protected Resource[][] grabResources(final FileSet[] filesets) {
final Resource[][] result = new Resource[filesets.length][];
for (int i = 0; i < filesets.length; i++) {
boolean skipEmptyNames = true;
if (filesets[i] instanceof ZipFileSet) {
final ZipFileSet zfs = (ZipFileSet) filesets[i];
skipEmptyNames = zfs.getPrefix(getProject()).isEmpty()
&& zfs.getFullpath(getProject()).isEmpty();
}
final DirectoryScanner rs =
filesets[i].getDirectoryScanner(getProject());
if (rs instanceof ZipScanner) {
((ZipScanner) rs).setEncoding(encoding);
}
final List<Resource> resources = new Vector<>();
if (!doFilesonly) {
for (String d : rs.getIncludedDirectories()) {
if (!(d.isEmpty() && skipEmptyNames)) {
resources.add(rs.getResource(d));
}
}
}
for (String f : rs.getIncludedFiles()) {
if (!(f.isEmpty() && skipEmptyNames)) {
resources.add(rs.getResource(f));
}
}
result[i] = resources.toArray(new Resource[resources.size()]);
}
return result;
}
示例9: getFileNames
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Grabs all included files and directors from the FileSet and
* returns them as an array of (relative) file names.
* @param fs the fileset to operate on.
* @return a list of the filenames.
* @since Ant 1.7
*/
protected static String[] getFileNames(final FileSet fs) {
final DirectoryScanner ds = fs.getDirectoryScanner(fs.getProject());
final String[] directories = ds.getIncludedDirectories();
final String[] filesPerSe = ds.getIncludedFiles();
final String[] files = new String[directories.length + filesPerSe.length];
System.arraycopy(directories, 0, files, 0, directories.length);
System.arraycopy(filesPerSe, 0, files, directories.length,
filesPerSe.length);
return files;
}
示例10: touch
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Does the actual work; assumes everything has been checked by now.
* @throws BuildException if an error occurs.
*/
protected void touch() throws BuildException {
long defaultTimestamp = getTimestamp();
if (file != null) {
touch(new FileResource(file.getParentFile(), file.getName()),
defaultTimestamp);
}
if (resources == null) {
return;
}
// deal with the resource collections
for (Resource r : resources) {
Touchable t = r.as(Touchable.class);
if (t == null) {
throw new BuildException("Can't touch " + r);
}
touch(r, defaultTimestamp);
}
// deal with filesets in a special way since the task
// originally also used the directories and Union won't return
// them.
for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
File fromDir = fs.getDir(getProject());
for (String srcDir : ds.getIncludedDirectories()) {
touch(new FileResource(fromDir, srcDir), defaultTimestamp);
}
}
}
示例11: getPackageList
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Return the comma-separated list of packages. The list is
* generated from Ant DirSet tasks, and includes all directories
* in a hierarchy, e.g. com, com/acme. com/acme/foo. Duplicates are
* ignored.
*/
protected String getPackageList(ProjectInfo proj) throws BuildException {
String packageList = "";
java.lang.StringBuffer sb = new StringBuffer();
Vector dirSets = proj.getDirsets();
int numDirSets = dirSets.size();
boolean addComma = false;
for (int i = 0; i < numDirSets; i++) {
DirSet dirSet = (DirSet)dirSets.elementAt(i);
DirectoryScanner dirScanner = dirSet.getDirectoryScanner(project);
String[] files = dirScanner.getIncludedDirectories();
for (int j = 0; j < files.length; j++) {
if (!addComma){
addComma = true;
} else {
sb.append(",");
}
sb.append(files[j]);
}
}
packageList = sb.toString();
if (packageList.compareTo("") == 0) {
throw new BuildException("Error: no packages found to scan");
}
project.log(" Package list: " + packageList, Project.MSG_INFO);
return packageList;
}
示例12: addConfiguredInputHeaders
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Adds input header directories.
*
* @param headers the input header directories
*/
public void addConfiguredInputHeaders(DirSet headers)
{
inputHeadersSpecified = true;
DirectoryScanner scanner = headers.getDirectoryScanner(getProject());
scanner.scan();
for (String directory: scanner.getIncludedDirectories())
this.inputHeaders.add(new File(scanner.getBasedir(), directory));
}
示例13: addConfiguredInputSources
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Adds input source directories.
*
* @param sources the input source directories
*/
public void addConfiguredInputSources(DirSet sources)
{
inputSourcesSpecified = true;
DirectoryScanner scanner = sources.getDirectoryScanner(getProject());
scanner.scan();
for (String directory: scanner.getIncludedDirectories())
this.inputSources.add(new File(scanner.getBasedir(), directory));
}
示例14: getSparkHome
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* This method is used to get spark home from plugin's jobtype config.
* If spark.{sparkVersion}.home is set in commonprivate.properties/private.properties, then that will be returned.
* If spark.{sparkVersion}.home is not set and spark.base.dir is set then it will retrieve Spark directory inside
* spark.base.dir, matching spark.home.prefix + sparkVersion pattern. Regex pattern can be passed as properties for
* version formatting.
* @param sparkVersion
* @return
*/
private String getSparkHome(String sparkVersion) {
String sparkHome = getSysProps().get("spark." + sparkVersion + ".home");
if (sparkHome == null) {
info("Couldn't find spark." + sparkVersion + ".home property.");
String sparkDir = getSysProps().get(SPARK_BASE_DIR);
String sparkHomePrefix =
getSysProps().get(SPARK_HOME_PREFIX) != null ? getSysProps().get(SPARK_HOME_PREFIX) : "*";
String replaceTo = getSysProps().get(SPARK_VERSION_REGEX_TO_REPLACE);
String replaceWith = getSysProps().get(SPARK_VERSION_REGEX_TO_REPLACE_WITH) != null ? getSysProps()
.get(SPARK_VERSION_REGEX_TO_REPLACE_WITH) : "";
String versionPatterToMatch =
sparkHomePrefix + ( replaceTo != null ? sparkVersion
.replace(replaceTo, replaceWith) : sparkVersion) + "*";
info("Looking for spark at " + sparkDir + " directory with " + sparkHomePrefix + " prefix for " + sparkVersion
+ " version.");
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(sparkDir);
scanner.setIncludes(new String[]{versionPatterToMatch});
scanner.scan();
String[] directories = scanner.getIncludedDirectories();
if (directories != null && directories.length > 0) {
sparkHome = sparkDir + "/" + directories[directories.length - 1];
} else {
String sparkReferenceDoc = getSysProps().get(SPARK_REFERENCE_DOCUMENT);
String exceptionMessage = sparkReferenceDoc == null ? "SPARK version specified by User is not available."
: "SPARK version specified by User is not available. Available versions are mentioned at: "
+ sparkReferenceDoc;
throw new RuntimeException(exceptionMessage);
}
}
return sparkHome;
}
示例15: searchFolders
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
public static String[] searchFolders(String searchPath, String searchString) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setIncludes(new String[]{searchString + "*"});
scanner.setExcludes(new String[]{searchString + "*.php"});
scanner.setBasedir(searchPath);
scanner.setCaseSensitive(false);
scanner.scan();
return scanner.getIncludedDirectories();
}