ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Le Rumeur Yves <lerum...@artenum.com>
Subject Example of implementation of Project from scratch
Date Wed, 05 May 2004 10:01:35 GMT

hie everybody,

	I'm new in ant project, and actually i succes to implement new ant
task, but now i want to implement unitary tess.
	For this purpose, i try to simulate a creation of project, target and
task and althought i read the different test implementation in this
project, i have trouble.
At first, i just want something very easy (see my joint code)
have you a little part of code which show how do this.

Thanks. 



public class SynchroTest {

	private static File file=null;
	private static Project proj=null;

	/**
	 * 
	 */
	public SynchroTest() {
		super();
	}

	public static void main(String[] args) {
		file=new File("/home/yves/labo/legogo.txt");
		Project popo = make_project();
		System.out.println("dfaz");

		
		popo.executeTarget("taskk");
	}
	
	public static Project make_project(){
		Project project = new Project();
		project.init();
		project.setCoreLoader(null);
		project.setName("TASKKK");
		project.setDescription("une project bidon pour les test!");
		project.setDefault("taskk");
		project.createTask("echo");
		project.addTaskDefinition("echo",Echo.class);
		project.addTarget(make_target());
		proj = project;
		return project;
	}
	
	public static Target make_target(){
		Target target = new Target();
		target.setDescription("un cible pour voir");
		target.setName("taskk");
		target.addTask(make_task(target));
		return target;
	}
	
	public static Task make_task(Target target){
		Echo echo = new Echo();
		echo.init();
		echo.setTaskName("C UNE GROSSE TACHE");
		echo.setOwningTarget(target);
		echo.setFile(file);
		Echo.EchoLevel po = new Echo.EchoLevel();
		po.setValue("info");
		echo.setLevel(po);
		echo.setProject(proj);
		echo.setTaskName("taskk");
		echo.setMessage("WOUHOUUUUUUU");
		//echo.execute();
		return echo;
	}
}

-- 
Yves


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message