gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
m2compile short javadoc
[pub/donny/ant-tasks.git] / com / quemaster / ant / m2 / m2compile.java
1 package com.quemaster.ant.m2;
3 import org.apache.tools.ant.BuildException;
4 import org.apache.tools.ant.Task;
5 import org.apache.tools.ant.taskdefs.condition.Os;
6 import java.util.ArrayList;
8 import java.io.*;
10 /**
11 m2compile is an Ant Task that executes a Modula 2 compiler on the give
12 module in the given dir. Currently it just assumes that the Native
13 XDS Modula 2 compiler "xc" is in the PATH, and if the OS is not
14 in the Windows family uses "wine" to execute it.
15 */
16 public class m2compile extends Task {
17 private String module="program";
18 private File dir=null;
22 // needs to check wheter the compilation is needed
23 // based on the timestamps of the exe and mod
25 // The method executing the task
26 public void execute() throws BuildException {
27 int exit = -1;
28 ArrayList<String> list = new ArrayList<String>();
29 if (!Os.isFamily(Os.FAMILY_WINDOWS))
30 list.add("wine");
31 list.add("xc");
32 list.add("=make");
33 list.add("=all");
34 list.add(module);
35 try{
36 ProcessBuilder pb = new ProcessBuilder(list);
37 pb.directory(dir);
38 pb.inheritIO();
40 Process p = pb.start();
41 p.waitFor();
42 exit = p.exitValue();
44 }catch (Exception ex) {
45 throw new BuildException(ex);
46 }
47 if (exit != 0)
48 throw new BuildException("compilation ended with code "+exit);
49 }
51 public void setModule(String msg) {
52 this.module = msg;
53 }
55 public void setDir(File msg) {
56 this.dir = msg;
57 }
59 public static void main(String[] args){
60 m2compile m = new m2compile();
62 m.execute();
63 }
64 }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner