package be.kuleuven.cs.distrinet.jlo.ant;

import java.io.File;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Path.PathElement;

import be.kuleuven.cs.distrinet.jlo.model.language.JLoProjectConfigurator;
import be.kuleuven.cs.distrinet.jlo.translate.AbstractTranslator;


public class AntRunTask extends AbstractTask {

	@Override
	public void execute() throws BuildException {
		Java java = new Java(this);
		java.setFork(true);
		java.setClassname(getClassname()+AbstractTranslator.IMPL);
		Path path = getClasspath();
		PathElement jlo_base = path.createPathElement();
		File loc = JLoProjectConfigurator.jloBase().getAbsoluteFile().getAbsoluteFile();
		jlo_base.setLocation(loc);
		path.add(jlo_base);
		
		path.addJavaRuntime();
		
		java.setClasspath(path);
		
		java.execute();
	}
	
	public void addClasspath(Path path) {
		_path = path;
	}
	
	public Path getClasspath() {
		return _path;
	}
	
	private Path _path;
	
	private String _className;
	
	public String getClassname() {
		return _className;
	}
	
	public void setClassname(String name) {
		_className = name;
	}
}

@@ -145,16 +145,62 @@
 s.Java;%0A
+import org.apache.tools.ant.types.Assertions;%0A
 import o
@@ -231,16 +231,16 @@
 s.Path;%0A
-
 import o
@@ -646,16 +646,86 @@
 .IMPL);%0A
+%09%09if(assertions() != null) %7B%0A%09%09%09java.addAssertions(assertions());%0A%09%09%7D%0A
 %09%09Path p
@@ -1054,16 +1054,82 @@
 path) %7B%0A
+%09%09setClasspath(path);%0A%09%7D%0A%09%0A%09public void setClasspath(Path path) %7B%0A
 %09%09_path 
@@ -1298,21 +1298,196 @@
 ssName;%0A
-
 %09%7D%0A%09%0A
+%09public Assertions assertions() %7B%0A%09%09return _assertions;%0A%09%7D%0A%09%0A%09public void addAssertions(Assertions asserts) %7B%0A%09%09_assertions = asserts;%0A%09%7D%0A%09%0A%09private Assertions _assertions;%0A%09%0A
 %09public 

support classpath attribute