本文整理汇总了Java中org.apache.tools.ant.FileScanner类的典型用法代码示例。如果您正苦于以下问题:Java FileScanner类的具体用法?Java FileScanner怎么用?Java FileScanner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileScanner类属于org.apache.tools.ant包,在下文中一共展示了FileScanner类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processGroupFilesets
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
/** Process groupfilesets */
private void processGroupFilesets() {
// Add the files found in groupfileset to fileset
for (FileSet fs : groupfilesets) {
logWhenWriting("Processing groupfileset ", Project.MSG_VERBOSE);
final FileScanner scanner = fs.getDirectoryScanner(getProject());
final File basedir = scanner.getBasedir();
for (String file : scanner.getIncludedFiles()) {
logWhenWriting("Adding file " + file + " to fileset",
Project.MSG_VERBOSE);
final ZipFileSet zf = new ZipFileSet();
zf.setProject(getProject());
zf.setSrc(new File(basedir, file));
add(zf);
filesetsFromGroupfilesets.add(zf);
}
}
}
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:Zip.java
示例2: execute
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
public void execute() throws BuildException {
for(FileSet fs: filesets) {
FileScanner scanner = fs.getDirectoryScanner(getProject());
File dir = scanner.getBasedir();
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
File helpset = new File(dir, files[i]);
try {
checkHelpSet(helpset);
} catch (BuildException be) {
throw be;
} catch (Exception e) {
throw new BuildException("Error checking helpset", e, new Location(helpset.getAbsolutePath()));
}
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CheckHelpSets.java
示例3: processExtraClassPathFileSets
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
private void processExtraClassPathFileSets() throws BuildException {
for (Iterator jarIter = mExtraClassPathFileSets.iterator(); jarIter
.hasNext();) {
FileSet fs = (FileSet) jarIter.next();
Project p = fs.getProject();
File srcDir = fs.getDir(p);
FileScanner ds = fs.getDirectoryScanner(p);
fs.setupDirectoryScanner(ds, p);
ds.scan();
String[] files = ds.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
File f = new File(srcDir, files[i]);
String path = f.getPath().replace(File.separatorChar, '/');
bundleProperties.addToExtraClassPath(path);
}
}
}
开发者ID:UltraMixer,项目名称:JarBundler,代码行数:21,代码来源:JarBundler.java
示例4: execute
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
public void execute () throws BuildException {
if (basedir == null) throw new BuildException ("Must specify the basedir attribute");
FileScanner scanner = getDirectoryScanner (basedir);
scanner.scan ();
String message = "Scanning for broken links in " + basedir + " ...";
if (! checkexternal) message += " (external URLs will be skipped)";
log (message);
String[] files = scanner.getIncludedFiles ();
Set<URI> okurls = new HashSet<>(1000);
Set<URI> badurls = new HashSet<>(100);
Set<URI> cleanurls = new HashSet<>(100);
List<String> errors = new ArrayList<>();
for (int i = 0; i < files.length; i++) {
File file = new File (basedir, files[i]);
URI fileurl = file.toURI();
log ("Scanning " + file, Project.MSG_VERBOSE);
try {
scan(this, null, null, getLocation().toString(), "", fileurl, okurls, badurls, cleanurls, checkexternal, checkspaces, checkforbidden, 1, mappers, filters, errors);
} catch (IOException ioe) {
throw new BuildException("Could not scan " + file + ": " + ioe, ioe, getLocation());
}
}
String testMessage = null;
if (!errors.isEmpty()) {
StringBuilder b = new StringBuilder("There were broken links");
for (String error : errors) {
b.append("\n" + error);
}
testMessage = b.toString();
}
JUnitReportWriter.writeReport(this, null, report, Collections.singletonMap("testBrokenLinks", testMessage));
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:CheckLinks.java
示例5: resolvePath
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
public File resolvePath(final AbstractProject project, final String path) throws IOException, InterruptedException {
File f = new File(path);
if (f.isAbsolute() && (!f.isFile() || !f.canExecute())) {
return null;
}
// For absolute paths
FormValidation validateExec = FormValidation.validateExecutable(path);
if (validateExec.kind == FormValidation.Kind.OK) {
return f;
}
// Ant style path definitions
FilePath workspace = project.getSomeWorkspace();
if (workspace != null) {
File workspaceRoot = new File(workspace.toURI());
FileSet fileSet = Util.createFileSet(workspaceRoot, path);
FileScanner fs = fileSet.getDirectoryScanner();
fs.setIncludes(new String[]{path});
fs.scan();
String[] includedFiles = fs.getIncludedFiles();
if (includedFiles.length > 0) {
File includedFile = new File(workspaceRoot, includedFiles[0]);
if (includedFile.exists() && includedFile.isFile() && includedFile.canExecute()) {
return includedFile;
}
}
}
return null;
}
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:33,代码来源:BrowserStackBuildWrapperDescriptor.java
示例6: processJarFileSets
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
private void processJarFileSets() throws BuildException {
for (Iterator jarIter = mJarFileSets.iterator(); jarIter.hasNext();) {
FileSet fs = (FileSet) jarIter.next();
Project p = fs.getProject();
File srcDir = fs.getDir(p);
FileScanner ds = fs.getDirectoryScanner(p);
fs.setupDirectoryScanner(ds, p);
ds.scan();
String[] files = ds.getIncludedFiles();
try {
for (int i = 0; i < files.length; i++) {
String fileName = files[i];
File src = new File(srcDir, fileName);
File dest = new File(mJavaDir, fileName);
if (mVerbose)
log("Copying JAR file to \"" + bundlePath(dest) + "\"");
mFileUtils.copyFile(src, dest);
bundleProperties.addToClassPath(fileName);
}
} catch (IOException ex) {
throw new BuildException("Cannot copy jar file: " + ex);
}
}
}
开发者ID:UltraMixer,项目名称:JarBundler,代码行数:34,代码来源:JarBundler.java
示例7: processCopyingFileSets
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
private void processCopyingFileSets(List fileSets, File targetdir, boolean setExec) {
for (Iterator execIter = fileSets.iterator(); execIter.hasNext();) {
FileSet fs = (FileSet) execIter.next();
Project p = fs.getProject();
File srcDir = fs.getDir(p);
FileScanner ds = fs.getDirectoryScanner(p);
fs.setupDirectoryScanner(ds, p);
ds.scan();
String[] files = ds.getIncludedFiles();
if (files.length == 0) {
// this is probably an error -- warn about it
System.err
.println("WARNING: fileset for copying from directory "
+ srcDir + ": no files found");
} else {
try {
for (int i = 0; i < files.length; i++) {
String fileName = files[i];
File src = new File(srcDir, fileName);
File dest = new File(targetdir, fileName);
if (mVerbose)
log("Copying "
+ (setExec ? "exec" : "resource")
+ " file to \"" + bundlePath(dest) +"\"");
mFileUtils.copyFile(src, dest);
if (setExec)
setExecutable(dest);
}
} catch (IOException ex) {
throw new BuildException("Cannot copy file: " + ex);
}
}
}
}
开发者ID:UltraMixer,项目名称:JarBundler,代码行数:39,代码来源:JarBundler.java
示例8: setupDirectoryScanner
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
/**
* Set up the specified directory scanner against the specified project.
* @param ds a <code>FileScanner</code> instance.
* @param p an Ant <code>Project</code> instance.
*/
public synchronized void setupDirectoryScanner(FileScanner ds, Project p) {
if (isReference()) {
getRef(p).setupDirectoryScanner(ds, p);
return;
}
dieOnCircularReference(p);
if (ds == null) {
throw new IllegalArgumentException("ds cannot be null");
}
ds.setBasedir(dir);
PatternSet ps = mergePatterns(p);
p.log(getDataTypeName() + ": Setup scanner in dir " + dir
+ " with " + ps, Project.MSG_DEBUG);
ds.setIncludes(ps.getIncludePatterns(p));
ds.setExcludes(ps.getExcludePatterns(p));
if (ds instanceof SelectorScanner) {
SelectorScanner ss = (SelectorScanner) ds;
ss.setSelectors(getSelectors(p));
}
if (useDefaultExcludes) {
ds.addDefaultExcludes();
}
ds.setCaseSensitive(caseSensitive);
}
开发者ID:apache,项目名称:ant,代码行数:32,代码来源:AbstractFileSet.java
示例9: processCopyingFileSets
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
private void processCopyingFileSets(List fileSets, File targetdir, boolean setExec) {
for (Iterator execIter = fileSets.iterator(); execIter.hasNext();) {
FileSet fs = (FileSet) execIter.next();
Project p = fs.getProject();
File srcDir = fs.getDir(p);
FileScanner ds = fs.getDirectoryScanner(p);
fs.setupDirectoryScanner(ds, p);
ds.scan();
String[] files = ds.getIncludedFiles();
if (files.length == 0) {
// this is probably an error -- warn about it
System.err
.println("WARNING: fileset for copying from directory "
+ srcDir + ": no files found");
} else {
try {
for (int i = 0; i < files.length; i++) {
String fileName = files[i];
File src = new File(srcDir, fileName);
File dest = new File(targetdir, fileName);
if (mVerbose)
log("Copying "
+ (setExec ? "exec" : "resource")
+ " file to \"" + bundlePath(dest) +"\"");
mFileUtils.copyFile(src, dest);
if (setExec)
setExecutable(dest);
}
} catch (IOException ex) {
throw new BuildException("Cannot copy file: " + ex);
}
}
}
}
开发者ID:tofi86,项目名称:Jarbundler,代码行数:40,代码来源:JarBundler.java
示例10: execute
import org.apache.tools.ant.FileScanner; //导入依赖的package包/类
public @Override void execute() throws BuildException {
if (fragment == null) {
if (fragments == null) {
throw new BuildException("You must supply a fragment", getLocation());
}
executeReplace();
return;
}
if (filesets.isEmpty()) {
throw new BuildException("You must supply at least one fileset", getLocation());
}
String failMsg = null;
try {
for (FileSet fileset : filesets) {
FileScanner scanner = fileset.getDirectoryScanner(getProject());
File baseDir = scanner.getBasedir ();
String[] files = scanner.getIncludedFiles ();
log ("Looking for " + fragment + " in " + files.length + " files in " + baseDir.getAbsolutePath ());
for (int i = 0; i < files.length; i++) {
File f = new File (baseDir, files[i]);
//log("Scanning " + f, Project.MSG_VERBOSE);
try (BufferedReader br = new BufferedReader (new FileReader (f))) {
String line;
while ((line = br.readLine ()) != null) {
if (line.indexOf (fragment) != -1) {
// Found it.
if (fail != null && "whenpresent".equals(fail.getValue())) {
if (failMsg != null) {
log(failMsg, Project.MSG_ERR);
}
failMsg = "License found in " + f;
}
break;
}
}
if (line == null) {
String msg = f.getAbsolutePath () + ":1: no license notice found";
if (fail != null && "whenmissing".equals(fail.getValue())) {
throw new BuildException(msg);
}
if (fail == null) {
// Scanned whole file without finding it.
log (msg, Project.MSG_ERR);
}
}
}
}
}
if (failMsg != null) {
throw new BuildException(failMsg);
}
} catch (IOException ioe) {
throw new BuildException("Could not open files to check licenses", ioe, getLocation());
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:59,代码来源:CheckLicense.java
注:本文中的org.apache.tools.ant.FileScanner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论