test/java/fr/jayasoft/ivy/ant/AntCallTriggerTest.java
// the only available way I found to easily run ant exits jvm at the end

the only available way I found to easily run ant exits jvm at the end
the only available way I found to easily run ant exits jvm at the end
private void runBuild(File buildFile, Vector targets, int messageLevel) throws BuildException {
        final Project project = new Project();
        project.setCoreLoader(null);
        Throwable error = null;
        try {
            addBuildListeners(project, messageLevel);
            addInputHandler(project, null);
            PrintStream err = System.err;
            PrintStream out = System.out;
            InputStream in = System.in;
            SecurityManager oldsm = null;
            oldsm = System.getSecurityManager();
            try {
            	project.setDefaultInputStream(System.in);
                System.setIn(new DemuxInputStream(project));
                System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
                System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
                project.fireBuildStarted();
                project.init();
                project.setUserProperty("ant.version", Main.getAntVersion());
                project.setUserProperty("ant.file",
                                        buildFile.getAbsolutePath());
                ProjectHelper.configureProject(project, buildFile);
                if (targets.size() == 0) {
                    if (project.getDefaultTarget() != null) {
                        targets.addElement(project.getDefaultTarget());
                    }
                }
                project.executeTargets(targets);
            } finally {
                if (oldsm != null) {
                    System.setSecurityManager(oldsm);
                }
                System.setOut(out);
                System.setErr(err);
                System.setIn(in);
            }
        } catch (RuntimeException exc) {
            error = exc;
            throw exc;
        } catch (Error err) {
            error = err;
            throw err;
        } finally {
        	project.fireBuildFinished(error);
        }
    }
private void runBuild ( File buildFile , Vector targets , int messageLevel ) throws BuildException { final Project project = new Project ( ) ; project . setCoreLoader ( null ) ; Throwable error = null ; try { addBuildListeners ( project , messageLevel ) ; addInputHandler ( project , null ) ; PrintStream err = System . err ; PrintStream out = System . out ; InputStream in = System . in ; SecurityManager oldsm = null ; oldsm = System . getSecurityManager ( ) ; try { project . setDefaultInputStream ( System . in ) ; System . setIn ( new DemuxInputStream ( project ) ) ; System . setOut ( new PrintStream ( new DemuxOutputStream ( project , false ) ) ) ; System . setErr ( new PrintStream ( new DemuxOutputStream ( project , true ) ) ) ; project . fireBuildStarted ( ) ; project . init ( ) ; project . setUserProperty ( "ant.version" , Main . getAntVersion ( ) ) ; project . setUserProperty ( "ant.file" , buildFile . getAbsolutePath ( ) ) ; ProjectHelper . configureProject ( project , buildFile ) ; if ( targets . size ( ) == 0 ) { if ( project . getDefaultTarget ( ) != null ) { targets . addElement ( project . getDefaultTarget ( ) ) ; } } project . executeTargets ( targets ) ; } finally { if ( oldsm != null ) { System . setSecurityManager ( oldsm ) ; } System . setOut ( out ) ; System . setErr ( err ) ; System . setIn ( in ) ; } } catch ( RuntimeException exc ) { error = exc ; throw exc ; } catch ( Error err ) { error = err ; throw err ; } finally { project . fireBuildFinished ( error ) ; } }
the only available way I found to easily run ant exits jvm at the end
the only available way I found to easily run ant exits jvm at the end
// use a system manager that prevents from System.exit()
 //SecurityManager can not be installed here for backwards
 //compatibility reasons (PD). Needs to be loaded prior to
 //ant class if we are going to implement it.
 //System.setSecurityManager(new NoExitSecurityManager());
 // make sure that we have a target to execute
 // put back the original security manager
 //The following will never eval to true. (PD)
