Java Code Examples for org.apache.tools.ant.taskdefs.Delete#execute()

The following examples show how to use org.apache.tools.ant.taskdefs.Delete#execute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IvyCacheFilesetTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 2
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    TestHelper.cleanCache();
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(new File("build/test/retrieve"));
    del.execute();
}
 
Example 3
Source File: DefaultRepositoryCacheManagerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() {
    IvyContext.popContext();
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(cacheManager.getRepositoryCacheRoot());
    del.execute();
}
 
Example 4
Source File: AntFile.java    From antiplag with Apache License 2.0 5 votes vote down vote up
public static int deleteDir(File f){
	int res = -1;
   	try {
		Project prj=new Project(); 
		Delete delete=new Delete(); 
		delete.setProject(prj); 
		delete.setDir(f); //��ͬʱ����Ŀ¼�������ļ�ɾ�� 
		delete.execute();
		res = 1;
	} catch (BuildException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} 
   	return res;
}
 
Example 5
Source File: AntFile.java    From antiplag with Apache License 2.0 5 votes vote down vote up
public static int deleteFile(File f){
	int res = -1;
   	try {
		Project prj=new Project(); 
		Delete delete=new Delete(); 
		delete.setProject(prj); 
		delete.setFile(f); //��ͬʱ����Ŀ¼�������ļ�ɾ�� 
		delete.execute();
		res = 1;
	} catch (BuildException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} 
   	return res;
}
 
Example 6
Source File: JNLPUpdateManifestStartup.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void deleteTmpFile(File tmpFile) {
    final Delete del = new Delete();
    del.setFile(tmpFile);
    del.execute();
}
 
Example 7
Source File: JNLPUpdateManifestBranding.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void deleteTmpFile(File tmpFile) {
    final Delete del = new Delete();
    del.setFile(tmpFile);
    del.execute();
}
 
Example 8
Source File: CustomJavac.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example 9
Source File: MakeJNLP.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void deleteTmpFile(File tmpFile) {
    final Delete del = new Delete();
    del.setFile(tmpFile);
    del.execute();
}
 
Example 10
Source File: IvyDeliverTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void cleanTestDir() {
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(new File("build/test/deliver"));
    del.execute();
}
 
Example 11
Source File: IvyDeliverTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void cleanRetrieveDir() {
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(new File("build/test/retrieve"));
    del.execute();
}
 
Example 12
Source File: IvyDeliverTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void cleanRep() {
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(new File("test/repositories/1/apache"));
    del.execute();
}
 
Example 13
Source File: IvyPublishTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void cleanRep() {
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(new File("test/repositories/1/apache"));
    del.execute();
}
 
Example 14
Source File: TestHelper.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public static void cleanCache() {
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(cache);
    del.execute();
}
 
Example 15
Source File: TestPerformance.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void cleanRepo() {
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(new File("build/test/perf"));
    del.execute();
}
 
Example 16
Source File: InstallTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void cleanInstall() {
    Delete del = new Delete();
    del.setProject(new Project());
    del.setDir(new File("build/test/install"));
    del.execute();
}