本文整理匯總了Java中org.apache.tools.ant.types.FileSet.setDir方法的典型用法代碼示例。如果您正苦於以下問題:Java FileSet.setDir方法的具體用法?Java FileSet.setDir怎麽用?Java FileSet.setDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tools.ant.types.FileSet
的用法示例。
在下文中一共展示了FileSet.setDir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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;
}
示例3: getFilesByNameEntryFilter
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
/**
* Returns a list of files found in a given folder, matching a given filter.
* @param folder the folder to search
* @param filters the filter for the files. Typically a glob.
* @return an iterator.
*/
private Iterator<?> getFilesByNameEntryFilter(String folder, String... filters) {
Project taskProject = getProject();
// create a fileset to find all the files in the folder
FileSet fs = new FileSet();
fs.setProject(taskProject);
fs.setDir(new File(folder));
for (String filter : filters) {
NameEntry include = fs.createInclude();
include.setName(filter);
}
// loop through the results of the file set
return fs.iterator();
}
示例4: packageConsole
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
private void packageConsole() throws CreatorExecutionException {
try {
Jar jarArchiver = new Jar();
jarArchiver.setProject(new Project());
jarArchiver.setDestFile(destinationWar);
final FileSet fileSet = new FileSet();
fileSet.setDir(workingDirectory);
jarArchiver.addFileset(fileSet);
jarArchiver.addConfiguredManifest(createManifest());
jarArchiver.execute();
} catch (ManifestException e) {
throw new CreatorExecutionException(e.getMessage(), e);
}
}
示例5: copyFiles
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
/**
* Move java or class files to temp files or moves the temp files back to
* java or class files. This must be done because javac is too nice and
* sticks already compiled classes and ones depended on in the classpath
* destroying the compile time wall. This way, we can keep the wall up.
*
* @param srcDir
* Directory to copy files from/to(Usually the java files dir or
* the class files dir)
* @param fileset
* The fileset of files to include in the move.
* @param moveToTempFile
* true if moving src files to temp files, false if moving temp
* files back to src files.
* @param isJavaFiles
* true if we are moving .java files, false if we are moving
* .class files.
*/
private void copyFiles(File srcDir, File destDir, FileSet fileset) {
fileset.setDir(srcDir);
if (!srcDir.exists())
throw new BuildException("Directory=" + srcDir + " does not exist", getLocation());
// before we do this, we have to move all files not
// in the above fileset to xxx.java.ant-tempfile
// so that they don't get dragged into the compile
// This way we don't miss anything and all the dependencies
// are listed or the compile will break.
Copy move = (Copy) getProject().createTask("SilentCopy");
move.setProject(getProject());
move.setOwningTarget(getOwningTarget());
move.setTaskName(getTaskName());
move.setLocation(getLocation());
move.setTodir(destDir);
// move.setOverwrite(true);
move.addFileset(fileset);
move.perform();
}
示例6: verifyPathAdheresToDesign
import org.apache.tools.ant.types.FileSet; //導入方法依賴的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);
}
}
示例7: execute
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
/**
* @see org.apache.tools.ant.Task#execute()
*/
@Override
public void execute() throws BuildException {
if (!ClassPathTask.TARGET_CLASSPATH.equalsIgnoreCase(this.produce)
&& !ClassPathTask.TARGET_FILESET.equals(this.produce)) {
throw new BuildException("Mandatory target must be either '" + ClassPathTask.TARGET_CLASSPATH + "' or '"
+ ClassPathTask.TARGET_FILESET + "'");
}
final ClassPathParser parser = new ClassPathParser();
AbstractCustomHandler handler;
if (ClassPathTask.TARGET_CLASSPATH.equalsIgnoreCase(this.produce)) {
final Path path = new Path(this.getProject());
this.getProject().addReference(this.idContainer, path);
handler = new PathCustomHandler(path);
} else {
final FileSet fileSet = new FileSet();
this.getProject().addReference(this.idContainer, fileSet);
fileSet.setDir(new File(this.getProject().getBaseDir().getAbsolutePath().toString()));
handler = new FileSetCustomHandler(fileSet);
}
parser.parse(new File(this.getProject().getBaseDir().getAbsolutePath(), ".classpath"), handler);
}
示例8: compress
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
/**
* ʹ��zipѹ���ļ�
*
* @param source
* ��Ҫѹ�����ļ�
* @param target
* ѹ�����ļ��Ĵ��·��
* @param delflag
* ѹ�����Ƿ�ɾ��Դ�ļ�
*/
public static void compress(File source, File target, boolean delflag) {
if (!target.exists()) {
target.mkdirs();
}
File zipFile = new File(target.getAbsolutePath() + File.separator
+ source.getName() + ".zip");
Project prj = new Project();
org.apache.tools.ant.taskdefs.Zip zip = new org.apache.tools.ant.taskdefs.Zip();
zip.setProject(prj);
zip.setDestFile(zipFile);
FileSet fileSet = new FileSet();
fileSet.setProject(prj);
fileSet.setDir(target);
// ������Щ�ļ����ļ���
fileSet.setIncludes(source.getName());
// �ų���Щ�ļ����ļ���
fileSet.setExcludes("*.zip");
zip.addFileset(fileSet);
zip.execute();
if (delflag) {
source.delete();
}
}
示例9: setUp
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
@Before
public void setUp() {
TestHelper.cleanCache();
project = TestHelper.newProject();
project.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath());
AntWorkspaceResolver antWorkspaceResolver = new AntWorkspaceResolver();
antWorkspaceResolver.setName("test-workspace");
wa = antWorkspaceResolver.createArtifact();
FileSet fileset = new FileSet();
fileset.setProject(project);
fileset.setDir(new File("test/workspace"));
fileset.setIncludes("*/ivy.xml");
antWorkspaceResolver.addConfigured(fileset);
antWorkspaceResolver.setProject(project);
configure = new IvyConfigure();
configure.setProject(project);
configure.setFile(new File("test/workspace/ivysettings.xml"));
configure.addConfiguredWorkspaceResolver(antWorkspaceResolver);
configure.execute();
}
示例10: testReverse
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
@Test
public void testReverse() {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml");
buildlist.addFileset(fs);
buildlist.setReverse(true);
buildlist.setOnMissingDescriptor("skip");
String[] files = getFiles(buildlist);
assertEquals(5, files.length);
assertListOfFiles("test/buildlist/", new String[] {"E", "D", "A", "C", "B"}, files);
}
示例11: shouldRunEvenIfTargetDoesntExistsInSubModules
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
@Test
public void shouldRunEvenIfTargetDoesntExistsInSubModules() throws URISyntaxException {
configureBuildLogger(submodule.getProject(), Project.MSG_DEBUG);
Path path = new Path(submodule.getProject());
FileSet fs = new FileSet();
File multimodule = new File(this.getClass().getResource("multimodule").toURI());
fs.setDir(multimodule);
path.addFileset(fs);
path.createPath();
submodule.setBuildpath(path);
submodule.setTarget("a-missing-target");
submodule.execute();
assertLogContaining("Executing [a-missing-target] on module1");
assertLogContaining("Skipping undefined target 'a-missing-target' on module1");
assertLogContaining("Executing [a-missing-target] on module2");
assertLogContaining("Skipping undefined target 'a-missing-target' on module2");
assertLogContaining("Skipping sub-project build because no matching targets were found");
}
示例12: testWithRootExclude
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
@Test
public void testWithRootExclude() {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
buildlist.addFileset(fs);
buildlist.setRoot("C");
buildlist.setExcludeRoot(true);
buildlist.setOnMissingDescriptor("skip");
String[] files = getFiles(buildlist);
assertEquals(1, files.length); // A, D and C should be filtered out
assertListOfFiles("test/buildlist/", new String[] {"B"}, files);
}
示例13: shouldRunMyTargetOnBothModule
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
@Test
public void shouldRunMyTargetOnBothModule() throws URISyntaxException {
configureBuildLogger(submodule.getProject(), Project.MSG_DEBUG);
Path path = new Path(submodule.getProject());
FileSet fs = new FileSet();
File multimodule = new File(this.getClass().getResource("multimodule").toURI());
fs.setDir(multimodule);
path.addFileset(fs);
path.createPath();
submodule.setBuildpath(path);
submodule.setTarget("modulewithtarget:mytarget");
submodule.execute();
assertLogContaining("Executing [modulewithtarget:mytarget] on module1");
assertLogContaining("Executing [modulewithtarget:mytarget] on module2");
assertThat(submodule.getProject().getReference(MultiModuleLogger.EXECUTION_TIMER_BUILD_RESULTS),
notNullValue());
}
示例14: copyFiles
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
public void copyFiles(File sourceFile,File destinationDirectory,String filter){
if (sourceFile.isFile()){
this.setFile(sourceFile);
}else {
FileSet fileset = new FileSet();
fileset.setDir(sourceFile);
if (filter!=null){
if (filter.matches("\\.\\w*")){
fileset.setIncludes("*/**/*"+filter);
}
}
this.addFileset(fileset);
}
this.setTodir(destinationDirectory);
this.perform();
}
示例15: testWithLeafAndOnlyDirectDep
import org.apache.tools.ant.types.FileSet; //導入方法依賴的package包/類
@Test
public void testWithLeafAndOnlyDirectDep() {
FileSet fs = new FileSet();
fs.setDir(new File("test/buildlist"));
fs.setIncludes("**/build.xml");
fs.setExcludes("E2/**");
buildlist.addFileset(fs);
buildlist.setOnMissingDescriptor("skip");
buildlist.setLeaf("C");
buildlist.setOnlydirectdep(true);
String[] files = getFiles(buildlist);
assertEquals(2, files.length); // We must have only A and C
assertListOfFiles("test/buildlist/", new String[] {"C", "A"}, files);
}