本文整理匯總了Java中org.apache.tools.ant.DirectoryScanner.getBasedir方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryScanner.getBasedir方法的具體用法?Java DirectoryScanner.getBasedir怎麽用?Java DirectoryScanner.getBasedir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tools.ant.DirectoryScanner
的用法示例。
在下文中一共展示了DirectoryScanner.getBasedir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
示例4: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Execute the task.
*
* @throws BuildException if the task fails.
*/
@Override
public void execute() throws BuildException {
validate();
final LibraryDisplayer displayer = new LibraryDisplayer();
// Check if list of files to check has been specified
if (libraryFileSets.isEmpty()) {
displayer.displayLibrary(libraryFile);
} else {
for (FileSet fileSet : libraryFileSets) {
final DirectoryScanner scanner =
fileSet.getDirectoryScanner(getProject());
final File basedir = scanner.getBasedir();
for (String filename : scanner.getIncludedFiles()) {
displayer.displayLibrary(new File(basedir, filename));
}
}
}
}
示例5: getExtensions
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Retrieve extensions from the specified libraries.
*
* @param libraries the filesets for libraries
* @return the extensions contained in libraries
* @throws BuildException if failing to scan libraries
*/
private static Extension[] getExtensions(final Project project,
final List<FileSet> libraries)
throws BuildException {
final List<Extension> extensions = new ArrayList<>();
for (FileSet fileSet : libraries) {
boolean includeImpl = true;
boolean includeURL = true;
if (fileSet instanceof LibFileSet) {
LibFileSet libFileSet = (LibFileSet) fileSet;
includeImpl = libFileSet.isIncludeImpl();
includeURL = libFileSet.isIncludeURL();
}
final DirectoryScanner scanner = fileSet.getDirectoryScanner(project);
final File basedir = scanner.getBasedir();
final String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
final File file = new File(basedir, files[ i ]);
loadExtensions(file, extensions, includeImpl, includeURL);
}
}
return extensions.toArray(new Extension[extensions.size()]);
}
示例6: createDirectory
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private Directory createDirectory(final FileSet set) {
final DirectoryScanner scanner = set.getDirectoryScanner(getProject());
final String[] files = scanner.getIncludedFiles();
if (files.length == 0) {
// skip
return null;
}
Directory root = new Directory(scanner.getBasedir());
Stream.of(files).map(Directory::getPath).forEach(path -> {
Directory current = root;
File currentParent = scanner.getBasedir();
for (String element : path) {
final File file = new File(currentParent, element);
if (file.isDirectory()) {
current.addDirectory(new Directory(file));
current = current.getChild(file);
currentParent = current.getDirectory();
} else if (file.isFile()) {
current.addFile(file);
}
}
});
return root;
}
示例7: filesetsToURL
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* convert the filesets to urls.
*
* @return null for no files
*/
private String filesetsToURL() {
if (filesets.isEmpty()) {
return "";
}
int count = 0;
StringBuilder urls = new StringBuilder();
for (FileSet fs : filesets) {
DirectoryScanner scanner = fs.getDirectoryScanner(getProject());
for (String file : scanner.getIncludedFiles()) {
File f = new File(scanner.getBasedir(), file);
validateFile(f);
String asUrl = toURL(f);
urls.append(asUrl);
log(asUrl, Project.MSG_DEBUG);
urls.append(separator);
count++;
}
}
//at this point there is one trailing space to remove, if the list is not empty.
return stripTrailingSeparator(urls, count);
}
示例8: getInFiles
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
public Iterator<File> getInFiles() {
ArrayList<File> inFiles = new ArrayList<File>(features.size());
for (AbstractFeature feat : features) {
if (feat.isIfConditionValid() && feat.isUnlessConditionValid()) {
if (feat instanceof LdTask.FileSetArgument) {
LdTask.FileSetArgument arg = (LdTask.FileSetArgument) feat;
DirectoryScanner scanner = arg.getFileSet().getDirectoryScanner(getProject());
String[] files = scanner.getIncludedFiles();
for(int i = 0; i < files.length; i++) {
File basePath = scanner.getBasedir();
inFiles.add(new File(basePath, files[i]));
}
}
}
}
return inFiles.iterator();
}
示例9: createPluginsManager
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
/**
* Initialize a plugin manager, using the specified temporary working
* directory.
* @param tempPluginsDir
* @return
* @throws IOException
*/
public static PluginsManager createPluginsManager(Path tempPluginsDir, List<FileSet> filesets) throws IOException {
// FileSet handling
for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner();
ds.scan();
File baseDir = ds.getBasedir();
for (String filename : ds.getIncludedFiles()) {
File f = new File(baseDir, filename);
TaskUtil.copyJarToDirectory(tempPluginsDir, f, false);
}
}
PluginsManager plManager = new PluginsManager();
System.out.println("Discovering from " + tempPluginsDir.toFile());
plManager.discover(tempPluginsDir.toFile(), false);
return plManager;
}
示例10: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
public @Override void execute() throws BuildException {
try {
if(isReady()) {
for(FileSet currFileSet: fileSets) {
DirectoryScanner ds = currFileSet.getDirectoryScanner(getProject());
String[] includedFiles = ds.getIncludedFiles();
for(int i=0; i<includedFiles.length; i++) {
File toCompress = new File(ds.getBasedir(), includedFiles[i].replace('\\','/'));
getCompiler().compile(toCompress, getOutputFile(toCompress));
}
}
}
else
throw new BuildException("Not all of the required parameters were specified");
}
catch(IOException io) {
throw new BuildException("An IO Exception occurred", io);
}
catch(CompilationException ce) {
throw new BuildException("An CompilationException occurred", ce);
}
}
示例11: processSetToDirMultiThreaded
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private void processSetToDirMultiThreaded(S3Service service) throws ServiceException, IOException {
List<S3Object> s3objects = new ArrayList<S3Object>();
long totalLength = 0;
this.project.log("Collecting objects for multithreaded upload to s3://" + getOperationBucket().getName(), Project.MSG_INFO);
for (FileSet fileSet : this.fileSets) {
DirectoryScanner ds = fileSet.getDirectoryScanner(this.project);
String[] includedFiles = ds.getIncludedFiles();
for (String file : includedFiles) {
File sourceFile = new File(ds.getBasedir(), file);
S3Object s3Object = createS3Object(service, getOperationBucket(), sourceFile, this.toDir + "/" + file);
s3objects.add(s3Object);
totalLength += sourceFile.length();
logStart(sourceFile, s3Object);
}
}
putFiles(service, getOperationBucket(), s3objects.toArray(new S3Object[s3objects.size()]), totalLength);
}
示例12: getFile
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
private File getFile(final Artifact artifact, final String includes, final String excludes) {
final FileSet fileSet = this.getFileSet(artifact, includes, excludes);
if (fileSet == null) {
return null;
}
final DirectoryScanner scanner = fileSet.getDirectoryScanner();
if (scanner.getIncludedFilesCount() > 1) {
return null;
}
final String fileName = scanner.getIncludedFiles()[0];
return new File(scanner.getBasedir(), fileName);
}
示例13: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
public void execute() throws BuildException {
if (target == null) {
throw new BuildException ("Target must be set"); // NOI18N
}
if (set == null) {
throw new BuildException ("Set of files must be provided: " + set); // NOI18N
}
DirectoryScanner scan = set.getDirectoryScanner(this.getProject());
File bdir = scan.getBasedir();
for (String n : scan.getIncludedFiles()) {
File f = new File(bdir, n);
parseForClasses (f);
}
try {
log ("Generating list of all classes to " + target);
try (PrintStream ps = new PrintStream (new BufferedOutputStream (
new FileOutputStream (target)
))) {
if (target.getName ().endsWith (".xml")) {
printClassesAsXML (ps);
} else {
printClassesAsHtml (ps);
}
}
} catch (IOException ex) {
throw new BuildException (ex);
}
}
示例14: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
@Override
public void execute() throws BuildException {
for (FileSet fs : manifests) {
DirectoryScanner scanner = fs.getDirectoryScanner(getProject());
File basedir = scanner.getBasedir();
for (String include : scanner.getIncludedFiles()) {
File manifest = new File(basedir, include);
log("Scanning: " + manifest, Project.MSG_VERBOSE);
try {
try (InputStream is = new FileInputStream(manifest)) {
BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String line;
while ((line = r.readLine()) != null) {
if (line.startsWith("#")) {
continue;
}
if (line.trim().length() == 0) {
continue;
}
String[] hashAndFile = line.split(" ", 2);
if (hashAndFile.length < 2) {
throw new BuildException("Bad line '" + line + "' in " + manifest, getLocation());
}
if (MavenCoordinate.isMavenFile(hashAndFile[1])) {
MavenCoordinate mc = MavenCoordinate.fromGradleFormat(hashAndFile[1]);
fillInFile(hashAndFile[0], mc.toArtifactFilename(), manifest, () -> mavenFile(mc));
} else {
fillInFile(hashAndFile[0], hashAndFile[1], manifest, () -> legacyDownload(hashAndFile[0] + "-" + hashAndFile[1]));
}
}
}
} catch (IOException x) {
throw new BuildException("Could not open " + manifest + ": " + x, x, getLocation());
}
}
}
}
示例15: execute
import org.apache.tools.ant.DirectoryScanner; //導入方法依賴的package包/類
public @Override void execute() throws BuildException {
Map<String,String> results = new LinkedHashMap<>();
for (FileSet fs : filesets) {
DirectoryScanner s = fs.getDirectoryScanner(getProject());
File basedir = s.getBasedir();
for (String incl : s.getIncludedFiles()) {
validate(new File(basedir, incl), results);
}
}
JUnitReportWriter.writeReport(this, null, failOnError ? null : report, results);
}