KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > savant > ant > AntLocalProjectBuilder


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

4 package com.inversoft.savant.ant;
5
6
7 import java.io.File JavaDoc;
8
9 import org.apache.tools.ant.Project;
10 import org.apache.tools.ant.taskdefs.Ant;
11
12 import com.inversoft.savant.LocalProject;
13 import com.inversoft.savant.LocalProjectBuilder;
14
15
16 /**
17  * <p>
18  * This class is the local project builder that uses the ant
19  * framework to call out to another ant build file.
20  * </p>
21  *
22  * @author Brian Pontarelli
23  */

24 public class AntLocalProjectBuilder implements LocalProjectBuilder {
25
26     private Project antProject;
27
28
29     public AntLocalProjectBuilder(Project antProject) {
30         this.antProject = antProject;
31     }
32
33
34     /**
35      * Builds the given LocalProject.
36      */

37     public void build(LocalProject project) {
38         // Test if the project exists and if not, bail
39
File JavaDoc test = new File JavaDoc(project.getDir(), project.getAntfile());
40         if (!test.exists()) {
41             return;
42         }
43
44         Ant ant = (Ant) antProject.createTask("ant");
45         ant.setAntfile(project.getAntfile());
46         ant.setDir(project.getDir());
47         ant.setInheritAll(false);
48         ant.setInheritRefs(false);
49
50         if (project.getTarget() != null) {
51             ant.setTarget(project.getTarget());
52         }
53
54         ant.perform();
55     }
56 }
57
Popular Tags