gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
5ba7a9eb0c84544db735fc7db9f48de13d90ff56
[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 public class m2compile extends Task {
11 private String module="program";
12 private File dir=null;
16 // needs to check wheter the compilation is needed
17 // based on the timestamps of the exe and mod
19 // The method executing the task
20 public void execute() throws BuildException {
21 int exit = -1;
22 ArrayList<String> list = new ArrayList<String>();
23 if (!Os.isFamily(Os.FAMILY_WINDOWS))
24 list.add("wine");
25 list.add("xc");
26 list.add("=make");
27 list.add("=all");
28 list.add(module);
29 try{
30 ProcessBuilder pb = new ProcessBuilder(list);
31 pb.directory(dir);
32 pb.inheritIO();
34 Process p = pb.start();
35 p.waitFor();
36 exit = p.exitValue();
38 }catch (Exception ex) {
39 throw new BuildException(ex);
40 }
41 if (exit != 0)
42 throw new BuildException("compilation ended with code "+exit);
43 }
45 public void setModule(String msg) {
46 this.module = msg;
47 }
49 public void setDir(File msg) {
50 this.dir = msg;
51 }
53 public static void main(String[] args){
54 m2compile m = new m2compile();
56 m.execute();
57 }
58 }
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner