本文整理匯總了Java中org.apache.tools.ant.DirectoryScanner.getIncludedFiles方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryScanner.getIncludedFiles方法的具體用法?Java DirectoryScanner.getIncludedFiles怎麽用?Java DirectoryScanner.getIncludedFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tools.ant.DirectoryScanner
的用法示例。
在下文中一共展示了DirectoryScanner.getIncludedFiles方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@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);
}
}
示例2: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public void execute() throws BuildException {
log( "Starting Hibernate EnhancementTask execution", Project.MSG_INFO );
// we use the CtClass stuff here just as a simple vehicle for obtaining low level information about
// the class(es) contained in a file while still maintaining easy access to the underlying byte[]
final Project project = getProject();
for ( FileSet fileSet : filesets ) {
final File fileSetBaseDir = fileSet.getDir( project );
final DirectoryScanner directoryScanner = fileSet.getDirectoryScanner( project );
for ( String relativeIncludedFileName : directoryScanner.getIncludedFiles() ) {
final File javaClassFile = new File( fileSetBaseDir, relativeIncludedFileName );
if ( ! javaClassFile.exists() ) {
continue;
}
processClassFile( javaClassFile);
}
}
}
示例3: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* 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]));
}
}
}
示例4: scanForFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private static void scanForFiles(Collection<File> destination, String pathAndMask) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setCaseSensitive(false);
String pathPart = FilenameUtils.getFullPath(pathAndMask);
if(StringUtils.isEmpty(pathPart))
{
scanner.setBasedir(Paths.get(".").toAbsolutePath().normalize().toFile());
scanner.setIncludes(new String[]{pathAndMask});
}
else
{
scanner.setBasedir(new File(pathPart));
scanner.setIncludes(new String[]{FilenameUtils.getName(pathAndMask)});
}
scanner.scan();
for (String file : scanner.getIncludedFiles()) {
destination.add(new File(scanner.getBasedir(),file));
}
}
示例5: 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 );
}
}
示例6: getInputFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* 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;
}
示例7: isIncluded
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Checks if passed file is scanned by any of the directory scanners.
*
* @param pathToFile a fully qualified path to tested file.
* @return true if so, false otherwise.
*/
public boolean isIncluded(String pathToFile)
{
Iterator scanners = directoryScanners.iterator();
while (scanners.hasNext())
{
DirectoryScanner scanner = (DirectoryScanner) scanners.next();
scanner.scan();
String[] includedFiles = scanner.getIncludedFiles();
for (int i = 0; i < includedFiles.length; i++)
{
File includedFile = new File(scanner.getBasedir(), includedFiles[i]);
if (pathToFile.equalsIgnoreCase(includedFile.getAbsolutePath()))
{
return true;
}
}
}
return false;
}
示例8: listFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public List<File> listFiles(final String mask) {
try {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setIncludes(new String[]{mask});
scanner.setBasedir(this.basedir.replace("\\", "/"));
scanner.setCaseSensitive(false);
scanner.scan();
String[] files = scanner.getIncludedFiles();
List<File> result = new ArrayList<>();
for (String file : files) {
result.add(
new SimpleFile(file,
FileUtils.readFileToByteArray(new java.io.File(basedir + "/" + file))));
}
return result;
} catch (IOException exception) {
throw new BootException(exception);
}
}
示例9: processFileSet
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private void processFileSet(final FileSet fileSet) throws IOException {
final DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject());
final String[] files = scanner.getIncludedFiles();
String base = fileSet.getDir(getProject()).getCanonicalPath() + "\\";
for (String file : files) {
String lastDir = "";
getDirFileList(lastDir);
int idx = -1;
do {
idx = file.indexOf('\\', idx + 1);
if (idx == -1) break;
lastDir = file.substring(0, idx);
getDirFileList(lastDir);
}
while (true);
List<String> fileList = getDirFileList(lastDir);
final String absolute = base + file;
fileList.add(absolute);
myAbsoluteToRelative.put(absolute, file);
}
}
示例10: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Invoke the Hadoop record compiler on each record definition file
*/
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]));
}
}
}
示例11: getSourceBundleFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
protected List<SourceBundleFile> getSourceBundleFiles(BundleSet bundleSet) {
List<SourceBundleFile> bundleFiles = new LinkedList<SourceBundleFile>();
ResourceType type = bundleSet.getType();
FileSet fs = bundleSet.getSourceFiles();
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] includedFiles = ds.getIncludedFiles();
File base = ds.getBasedir();
for (int i = 0; i < includedFiles.length; i++) {
File bundleFile = new File(base, includedFiles[i]);
bundleFiles.add(
new SourceBundleFile(type, pathToBundleId(type, includedFiles[i]),
bundleFile, includedFiles[i]));
}
return bundleFiles;
}
示例12: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
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 );
}
}
}
}
示例13: verifyPathAdheresToDesign
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private void verifyPathAdheresToDesign(Design d, Path p) throws ClassFormatException, IOException {
String files[] = p.list();
for (int i = 0; i < files.length; i++) {
File file = new File(files[i]);
if (file.isDirectory()) {
FileSet set = new FileSet();
set.setDir(file);
set.setProject(task.getProject());
PatternSet.NameEntry entry1 = set.createInclude();
PatternSet.NameEntry entry2 = set.createInclude();
PatternSet.NameEntry entry3 = set.createInclude();
entry1.setName("**/*.class");
entry2.setName("**/*.jar");
entry3.setName("**/*.war");
DirectoryScanner scanner = set.getDirectoryScanner(task.getProject());
scanner.setBasedir(file);
String[] scannerFiles = scanner.getIncludedFiles();
for (int j = 0; j < scannerFiles.length; j++) {
verifyPartOfPath(scannerFiles[j], new File(file, scannerFiles[j]), d);
}
} else
verifyPartOfPath(files[i], file, d);
}
}
示例14: getFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private String[] getFiles() {
List files = new LinkedList();
for ( Iterator i = fileSets.iterator(); i.hasNext(); ) {
FileSet fs = (FileSet) i.next();
DirectoryScanner ds = fs.getDirectoryScanner( getProject() );
String[] dsFiles = ds.getIncludedFiles();
for (int j = 0; j < dsFiles.length; j++) {
File f = new File(dsFiles[j]);
if ( !f.isFile() ) {
f = new File( ds.getBasedir(), dsFiles[j] );
}
files.add( f.getAbsolutePath() );
}
}
return ArrayHelper.toStringArray(files);
}
示例15: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* 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);
}
}