KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > savant > DefaultLocalProjectBuilder


1 /*
2  * Copyright (c) 2003-2004, Inversoft, All Rights Reserved
3  */

4 package com.inversoft.savant;
5
6
7 import java.io.IOException JavaDoc;
8
9
10 /**
11  * <p>
12  * This class is the default local project builder. This uses
13  * the java.lang.Runtime class to exec ant with the information
14  * from the local project.
15  * </p>
16  *
17  * @author Brian Pontarelli
18  */

19 public class DefaultLocalProjectBuilder implements LocalProjectBuilder {
20
21     /**
22      * Builds the given LocalProject.
23      */

24     public void build(LocalProject project) throws SavantException {
25         String JavaDoc[] cmd = new String JavaDoc[] {"ant", "-f", project.getAntfile(),
26             project.getTarget()};
27         try {
28             java.lang.Process JavaDoc process = Runtime.getRuntime().exec(cmd, null,
29                 project.getDir());
30             if (process.exitValue() != 0) {
31                 throw new SavantException("Build of project [" + project.getName() +
32                     "] failed");
33             }
34         } catch (IOException JavaDoc ioe) {
35             throw new SavantException("Unable to build local project [" +
36                 project.getName() + "] due to [" + ioe.getMessage() + "]");
37         }
38     }
39 }
40
Popular Tags