本文整理汇总了Java中org.apache.tools.ant.taskdefs.Delete类的典型用法代码示例。如果您正苦于以下问题:Java Delete类的具体用法?Java Delete怎么用?Java Delete使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Delete类属于org.apache.tools.ant.taskdefs包,在下文中一共展示了Delete类的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: execute
import org.apache.tools.ant.taskdefs.Delete; //导入依赖的package包/类
public void execute() throws Exception {
Delete t = new Delete();
t.setDir( project.getAntOutputDir() );
antTaskRunner.runTask( t );
File header = project.getDeployHeaderFile();
boolean del = header.delete();
System.out.println( "Delete header file=" + del );
File[] files = project.getDeployDir().listFiles( new FileFilter() {
public boolean accept( File pathname ) {
return !pathname.isDirectory();
}
} );
for ( int i = 0; i < files.length; i++ ) {
File file = files[i];
boolean deleted = file.delete();
System.out.println( "Delete " + file + " = " + deleted );
}
Delete d = new Delete();
d.setDir( project.getContribLicenseDir() );
antTaskRunner.runTask( d );
}
示例3: delDir
import org.apache.tools.ant.taskdefs.Delete; //导入依赖的package包/类
static public void delDir(File dir) {
final class AntDelete extends Delete {
@SuppressWarnings("deprecation")
public AntDelete() {
project = new Project();
project.init();
taskType = "delete";
taskName = "delete";
target = new Target();
}
}
AntDelete ant = new AntDelete();
ant.setDir(dir);
ant.execute();
}
示例4: 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();
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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();
}
示例8: clean
import org.apache.tools.ant.taskdefs.Delete; //导入依赖的package包/类
private void clean(File tempDirectory) {
Delete cleanupTask = new Delete();
cleanupTask.setProject(getProject());
cleanupTask.setTaskName(getTaskName());
cleanupTask.setLocation(getLocation());
cleanupTask.setDir(tempDirectory);
cleanupTask.perform();
}
示例9: 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;
}
示例10: 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;
}
示例11: maybeClearLocalRepo
import org.apache.tools.ant.taskdefs.Delete; //导入依赖的package包/类
/**
* If setup with a local repo, clean it
*/
private void maybeClearLocalRepo() {
File basedir = getLocalRepoBaseDir();
if (basedir == null) {
return;
}
log("Deleting the local repository '" + basedir + "'", Project.MSG_VERBOSE);
Delete delete = new Delete();
delete.setFailOnError(false);
delete.setDir(basedir);
}
示例12: 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();
}
示例13: 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();
}
示例14: 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();
}
示例15: 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();
}
}