Java Code Examples for org.apache.tools.ant.BuildException#printStackTrace()

The following examples show how to use org.apache.tools.ant.BuildException#printStackTrace() . 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: AntHarnessTest.java    From ExpectIt with Apache License 2.0 6 votes vote down vote up
@Test
public void runTarget() throws IOException {
    Project project = newProject();
    project.log("started: " + target);
    // prepare
    project.executeTarget("");
    boolean negative = target.endsWith("-negative");
    // run test
    try {
        project.executeTarget(target);
        if (negative) {
            fail("Negative test fails");
        }
    } catch (BuildException e) {
        e.printStackTrace();
        if (!negative) {
            fail("Positive test fails");
        }
    } finally {
        project.log("finished");
    }
}
 
Example 2
Source File: AntFile.java    From antiplag with Apache License 2.0 6 votes vote down vote up
public static int unzip(File src,File dest){
	int res = -1;
	try {
		Project prj=new Project(); 
		Expand expand=new Expand(); 
		expand.setProject(prj); 
		expand.setSrc(src); 
		expand.setOverwrite(true); 
		expand.setDest(dest); 
		expand.execute();
		res = 1;
	} catch (BuildException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();			
	} 
	return res;
}
 
Example 3
Source File: AntFile.java    From antiplag with Apache License 2.0 6 votes vote down vote up
public static int makeDir(File f){
	int res = -1;
	try {
		Project prj=new Project(); 
		Mkdir mkdir=new Mkdir(); 
		mkdir.setProject(prj); 
		mkdir.setDir(f); 
		mkdir.execute(); 
		res = 1;
	} catch (BuildException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	return res;
}
 
Example 4
Source File: AntFile.java    From antiplag with Apache License 2.0 6 votes vote down vote up
public static int rename(File srcf,File destf){
	int res = -1;
	
	try {
		Project prj=new Project(); 
		Move copy=new Move(); 
		copy.setProject(prj); 
		copy.setFile(srcf); 
		copy.setTofile(destf); 
		copy.execute(); //��f1.txt�ļ�����Ϊf2.txt�� 
		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 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 6
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 7
Source File: NbMerge.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Execute targets which can fail _without_ throwing BuildException */
private void modulesBuild() throws BuildException {
    if ( ! failonerror ) {
        // build the rest of modules
        for (String module : buildmodules) {
            dummy = new Target ();
            dummyName = "nbmerge-" + getOwningTarget().getName() + "-" + module;
            while (targets.contains (dummyName))
                dummyName += "-x";
            dummy.setName (dummyName);
            dummy.addDependency (targetprefix + module);
            getProject().addTarget(dummy);
            @SuppressWarnings("unchecked")
            Vector<Target> fullList = getProject().topoSort(dummyName, targets);
            // Now remove earlier ones: already done.
            @SuppressWarnings("unchecked")
            Vector<Target> doneList = getProject().topoSort(getOwningTarget().getName(), targets);
            List<Target> todo = new ArrayList<>(fullList.subList(0, fullList.indexOf(dummy)));
            todo.removeAll(doneList.subList(0, doneList.indexOf(getOwningTarget())));
            
            Iterator<Target> targit = todo.iterator();
            try {
                while (targit.hasNext()) {
                    Target nexttargit = targit.next();
                    String targetname = nexttargit.getName();
                    if ( builttargets.indexOf(targetname) < 0 ) {
                        System.out.println(); System.out.println(targetname + ":");
                        nexttargit.execute();
                        builttargets.addElement(targetname);
                    }
                    
                }
                builtmodules.addElement(module);
            } catch (BuildException BE) {
                    log(BE.toString(), Project.MSG_WARN);
                    BE.printStackTrace();
                    failedmodules.addElement(module);
            }
        }
        log("builtmodules=" + builtmodules, Project.MSG_VERBOSE);
        log("failedmodules=" + failedmodules, Project.MSG_VERBOSE);
    }
}