本文整理汇总了Java中org.apache.tools.ant.taskdefs.Delete.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Delete.execute方法的具体用法?Java Delete.execute怎么用?Java Delete.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tools.ant.taskdefs.Delete
的用法示例。
在下文中一共展示了Delete.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unZip
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
public static void unZip(String zipPath,String targetFolder,boolean cleanZip){
File folderFile =new File(targetFolder);
File zipFile = new File(zipPath);
Project prj = new Project();
Expand expand = new Expand();
expand.setEncoding("UTF-8");
expand.setProject(prj);
expand.setSrc(zipFile);
expand.setOverwrite(true);
expand.setDest(folderFile);
expand.execute();
if(cleanZip){
//清除zip包
Delete delete = new Delete();
delete.setProject(prj);
delete.setDir(zipFile);
delete.execute();
}
}
示例2: recursivelyDeleteDir
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
/**
* Delete a directory and all subdirectories
*/
public static void recursivelyDeleteDir(File customProfileDir) {
if (customProfileDir == null || !customProfileDir.exists()) {
return;
}
Delete delete = new Delete();
delete.setProject(new Project());
delete.setDir(customProfileDir);
delete.setFailOnError(true);
delete.execute();
}
示例3: testWithoutPreviousResolveAndNonDefaultCache
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
@Test
public void testWithoutPreviousResolveAndNonDefaultCache() {
File cache2 = new File("build/cache2");
cache2.mkdirs();
try {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
fileset.setSetid("simple-setid");
System.setProperty("ivy.cache.dir", cache2.getAbsolutePath());
fileset.execute();
Object ref = project.getReference("simple-setid");
assertNotNull(ref);
assertTrue(ref instanceof FileSet);
FileSet fs = (FileSet) ref;
DirectoryScanner directoryScanner = fs.getDirectoryScanner(project);
assertEquals(1, directoryScanner.getIncludedFiles().length);
assertEquals(
getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar", cache2)
.getAbsolutePath(), new File(directoryScanner.getBasedir(),
directoryScanner.getIncludedFiles()[0]).getAbsolutePath());
} finally {
Delete del = new Delete();
del.setProject(new Project());
del.setDir(cache2);
del.execute();
}
}
示例4: tearDown
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
@After
public void tearDown() {
TestHelper.cleanCache();
Delete del = new Delete();
del.setProject(new Project());
del.setDir(new File("build/test/retrieve"));
del.execute();
}
示例5: tearDown
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
@After
public void tearDown() {
IvyContext.popContext();
Delete del = new Delete();
del.setProject(new Project());
del.setDir(cacheManager.getRepositoryCacheRoot());
del.execute();
}
示例6: getTimeDiff
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
/**
* auto find the time difference between local and remote
* @param ftp handle to ftp client
* @return number of millis to add to remote time to make it comparable to local time
* @since ant 1.6
*/
private long getTimeDiff(FTPClient ftp) {
long returnValue = 0;
File tempFile = findFileName(ftp);
try {
// create a local temporary file
FILE_UTILS.createNewFile(tempFile);
long localTimeStamp = tempFile.lastModified();
BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath()));
ftp.storeFile(tempFile.getName(), instream);
instream.close();
if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
FTPFile [] ftpFiles = ftp.listFiles(tempFile.getName());
if (ftpFiles.length == 1) {
long remoteTimeStamp = ftpFiles[0].getTimestamp().getTime().getTime();
returnValue = localTimeStamp - remoteTimeStamp;
}
ftp.deleteFile(ftpFiles[0].getName());
}
// delegate the deletion of the local temp file to the delete task
// because of race conditions occurring on Windows
Delete mydelete = new Delete();
mydelete.bindToOwner(task);
mydelete.setFile(tempFile.getCanonicalFile());
mydelete.execute();
} catch (Exception e) {
throw new BuildException(e, task.getLocation());
}
return returnValue;
}
示例7: getTimeDiff
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
/**
* auto find the time difference between local and remote
* @param ftp handle to ftp client
* @return number of millis to add to remote time to make it comparable to local time
* @since ant 1.6
*/
private long getTimeDiff(FTPClient ftp) {
long returnValue = 0;
File tempFile = findFileName(ftp);
try {
// create a local temporary file
FILE_UTILS.createNewFile(tempFile);
long localTimeStamp = tempFile.lastModified();
BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath()));
ftp.storeFile(tempFile.getName(), instream);
instream.close();
boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode());
if (success) {
FTPFile [] ftpFiles = ftp.listFiles(tempFile.getName());
if (ftpFiles.length == 1) {
long remoteTimeStamp = ftpFiles[0].getTimestamp().getTime().getTime();
returnValue = localTimeStamp - remoteTimeStamp;
}
ftp.deleteFile(ftpFiles[0].getName());
}
// delegate the deletion of the local temp file to the delete task
// because of race conditions occurring on Windows
Delete mydelete = new Delete();
mydelete.bindToOwner(this);
mydelete.setFile(tempFile.getCanonicalFile());
mydelete.execute();
} catch (Exception e) {
throw new BuildException(e, getLocation());
}
return returnValue;
}
示例8: deleteDir
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
private static void deleteDir(Project project, File dir) {
Delete deleteTask = new Delete();
deleteTask.setProject(project);
deleteTask.setTaskName("delete dir");
deleteTask.setDir(dir);
deleteTask.execute();
}
示例9: deleteFile
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
private static void deleteFile(Project project, File file) {
Delete deleteTask = new Delete();
deleteTask.setProject(project);
deleteTask.setTaskName("delete file");
deleteTask.setFile(file);
deleteTask.execute();
}
示例10: cleanupTestDir
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
@After
public void cleanupTestDir() {
Delete delete = new Delete();
delete.setProject(new Project());
delete.setDir(testDir);
delete.setQuiet(true);
delete.setIncludeEmptyDirs(true);
delete.execute();
}
示例11: deleteFolder
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
public static void deleteFolder(File folder) {
if (folder.exists()) {
Delete delete = new Delete();
delete.setProject(new Project());
delete.setDir(folder);
delete.setIncludeEmptyDirs(true);
delete.setQuiet(true);
delete.execute();
}
}
示例12: deleteTmpFile
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
private static void deleteTmpFile(File tmpFile) {
final Delete del = new Delete();
del.setFile(tmpFile);
del.execute();
}
示例13: cleanUpStaleClasses
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
/**
* See issue #166888. If there are any existing class files with no matching
* source file, assume this is an incremental build and the source file has
* since been deleted. In that case, delete the whole classes dir. (Could
* merely delete the stale class file, but if an annotation processor also
* created associated resources, these may be stale too. Kill them all and
* let JSR 269 sort it out.)
*/
private void cleanUpStaleClasses() {
File d = getDestdir();
if (!d.isDirectory()) {
return;
}
List<File> sources = new ArrayList<>();
for (String s : getSrcdir().list()) {
sources.add(new File(s));
}
if (generatedClassesDir.isDirectory()) {
sources.add(generatedClassesDir);
}
FileSet classes = new FileSet();
classes.setDir(d);
classes.setIncludes("**/*.class");
classes.setExcludes("**/*$*.class");
String startTimeProp = getProject().getProperty("module.build.started.time");
Date startTime;
try {
startTime = startTimeProp != null ? new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(startTimeProp) : null;
} catch (ParseException x) {
throw new BuildException(x);
}
for (String clazz : classes.getDirectoryScanner(getProject()).getIncludedFiles()) {
if (startTime != null && new File(d, clazz).lastModified() > startTime.getTime()) {
// Ignore recently created classes. Hack to get contrib/j2ee.blueprints and the like
// to build; these generate classes and resources before main compilation step.
continue;
}
String java = clazz.substring(0, clazz.length() - ".class".length()) + ".java";
boolean found = false;
for (File source : sources) {
if (new File(source, java).isFile()) {
found = true;
break;
}
}
if (!found) {
// XXX might be a false negative in case this was a nonpublic outer class
// (could check for "ClassName.java" in bytecode to see)
log(new File(d, clazz) + " appears to be stale, rebuilding all module sources", Project.MSG_WARN);
Delete delete = new Delete();
delete.setProject(getProject());
delete.setOwningTarget(getOwningTarget());
delete.setLocation(getLocation());
FileSet deletables = new FileSet();
deletables.setDir(d);
delete.addFileset(deletables);
delete.init();
delete.execute();
break;
}
}
}
示例14: cleanTestDir
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
private void cleanTestDir() {
Delete del = new Delete();
del.setProject(new Project());
del.setDir(new File("build/test/deliver"));
del.execute();
}
示例15: cleanRetrieveDir
import org.apache.tools.ant.taskdefs.Delete; //导入方法依赖的package包/类
private void cleanRetrieveDir() {
Delete del = new Delete();
del.setProject(new Project());
del.setDir(new File("build/test/retrieve"));
del.execute();
}