本文整理匯總了Java中org.apache.tools.ant.types.FileSet類的典型用法代碼示例。如果您正苦於以下問題:Java FileSet類的具體用法?Java FileSet怎麽用?Java FileSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FileSet類屬於org.apache.tools.ant.types包,在下文中一共展示了FileSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.apache.tools.ant.types.FileSet; //導入依賴的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.types.FileSet; //導入依賴的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()));
}
}
}
}
示例3: execute
import org.apache.tools.ant.types.FileSet; //導入依賴的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);
}
}
}
示例4: compress
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
public static void compress(String desPath, String srcPath){
File desFile = new File(desPath);// 目標文件
File srcFile = new File(srcPath);// 源文件
if (!srcFile.exists())
throw new RuntimeException("需要壓縮的文件不存在");
Project project = new Project();
Zip zip = new Zip();
zip.setProject(project);
zip.setDestFile(desFile);
FileSet fileSet = new FileSet();
fileSet.setProject(project);
fileSet.setDir(srcFile);
zip.addFileset(fileSet);
zip.execute();
}
示例5: execute
import org.apache.tools.ant.types.FileSet; //導入依賴的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]));
}
}
}
示例6: compressExe
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
public File compressExe(File srcDir, String destZipPath) {
Project prj = new Project();
Zip zip = new Zip();
File dest = new File(destZipPath);
zip.setProject(prj);
zip.setDestFile(dest);
FileSet fileSet = new FileSet();
fileSet.setProject(prj);
fileSet.setDir(srcDir);
zip.addFileset(fileSet);
zip.execute();
File[] files = srcDir.listFiles();
for (int i = 0;i < files.length;i++) {
files[i].delete();
}
srcDir.delete();
return dest;
}
示例7: collect
import org.apache.tools.ant.types.FileSet; //導入依賴的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 );
}
}
示例8: getInputFiles
import org.apache.tools.ant.types.FileSet; //導入依賴的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;
}
示例9: getLibrariesConfiguration
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
/**
* @return a <code>FileMatchingConfiguration</code> object describing the
* configuration of all libraries added to this particular web app
* (both classes and libraries).
*/
public FileMatchingConfiguration getLibrariesConfiguration()
{
FileMatchingConfiguration config = new FileMatchingConfiguration();
Iterator classesIterator = classes.iterator();
while (classesIterator.hasNext())
{
FileSet clazz = (FileSet) classesIterator.next();
config.addDirectoryScanner(clazz.getDirectoryScanner(project));
}
Iterator librariesIterator = libraries.iterator();
while (librariesIterator.hasNext())
{
FileSet library = (FileSet) librariesIterator.next();
config.addDirectoryScanner(library.getDirectoryScanner(project));
}
return config;
}
示例10: testPathsOneFile
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
@Test
public final void testPathsOneFile() throws IOException {
// given
TestRootModuleChecker.reset();
final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE);
final FileSet examinationFileSet = new FileSet();
examinationFileSet.setFile(new File(getPath(FLAWLESS_INPUT)));
final Path sourcePath = new Path(antTask.getProject());
sourcePath.addFileset(examinationFileSet);
antTask.addPath(sourcePath);
// when
antTask.execute();
// then
assertTrue("Checker is not processed",
TestRootModuleChecker.isProcessed());
final List<File> filesToCheck = TestRootModuleChecker.getFilesToCheck();
assertThat("There more files to check then expected",
filesToCheck.size(), is(1));
assertThat("The path of file differs from expected",
filesToCheck.get(0).getAbsolutePath(), is(getPath(FLAWLESS_INPUT)));
}
示例11: testFileSet
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
@Test
public final void testFileSet() throws IOException {
TestRootModuleChecker.reset();
final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE);
final FileSet examinationFileSet = new FileSet();
examinationFileSet.setFile(new File(getPath(FLAWLESS_INPUT)));
antTask.addFileset(examinationFileSet);
antTask.execute();
assertTrue("Checker is not processed",
TestRootModuleChecker.isProcessed());
final List<File> filesToCheck = TestRootModuleChecker.getFilesToCheck();
assertThat("There more files to check then expected",
filesToCheck.size(), is(1));
assertThat("The path of file differs from expected",
filesToCheck.get(0).getAbsolutePath(), is(getPath(FLAWLESS_INPUT)));
}
示例12: execute
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
/**
* @see org.apache.tools.ant.Task#execute()
*/
@SuppressWarnings("unchecked")
@Override
public void execute() throws BuildException {
// See if this is a slave plugin
_slavePlugin = getProject().getProperty("slave.plugin").equalsIgnoreCase("true");
FileSet slaveFiles = (FileSet)getProject().getReference("slave.fileset");
_filePatterns = new ArrayList<String>();
// Get the build start time as long
SimpleDateFormat simpleBuildDate = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS");
Date buildDate = null;
try {
buildDate = simpleBuildDate.parse(getProject().getProperty("build.plugins.start"));
} catch (ParseException e) {
throw new BuildException("Plugin build timestamp not set correctly");
}
_longDate = buildDate.getTime();
_installedConfs = (ArrayList<String>)getProject().getReference("installed.confs");
findResources(_resourceDir);
if (_slavePlugin && !_filePatterns.isEmpty()) {
String[] patterns = _filePatterns.toArray(new String[_filePatterns.size()]);
slaveFiles.appendIncludes(patterns);
}
}
示例13: execute
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
/**
* @see org.apache.tools.ant.taskdefs.Zip#execute()
*/
@Override
public void execute() throws BuildException {
// See if this is a slave plugin
boolean slavePlugin = getProject().getProperty("slave.plugin").equalsIgnoreCase("true");
FileSet slaveFiles = (FileSet)getProject().getReference("slave.fileset");
// Run the actual Jar process
super.execute();
// Log created file if needed
if (slavePlugin) {
File zipFile = getDestFile();
String installDir = getProject().getProperty("installdir");
String relativePath = zipFile.getPath().substring(installDir.length()+1);
slaveFiles.appendIncludes(new String[]{relativePath});
}
}
示例14: execute
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
/**
* @see org.apache.tools.ant.taskdefs.Jar#execute()
*/
@Override
public void execute() throws BuildException {
// See if this is a slave plugin
boolean slavePlugin = getProject().getProperty("slave.plugin").equalsIgnoreCase("true");
FileSet slaveFiles = (FileSet)getProject().getReference("slave.fileset");
// Run the actual Jar process
super.execute();
// Log created file if needed
if (slavePlugin) {
File jarFile = getDestFile();
String installDir = getProject().getProperty("installdir");
String relativePath = jarFile.getPath().substring(installDir.length()+1);
slaveFiles.appendIncludes(new String[]{relativePath});
}
}
示例15: execute
import org.apache.tools.ant.types.FileSet; //導入依賴的package包/類
@Override
public void execute() throws BuildException {
try {
List<File> files = new ArrayList<File>();
for (FileSet fs : fileSets) {
String[] fileNames = fs.getDirectoryScanner().getIncludedFiles();
for (String fname : fileNames) {
File file = new File(fs.getDir(), fname);
if (file.getName().endsWith(".class")) {
files.add(file);
}
}
}
Instrumenter instr = new Instrumenter(files, destDir, stackPackageName);
instr.setDisabled(disabled);
instr.setSingleThread(singleThread);
instr.setIsolated(isolated);
instr.process();
}
catch (IOException e) {
throw new BuildException(e);
}
}