KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > forrest > eclipse > job > ForrestBuilder


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation or its licensors,
3  * as applicable.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.forrest.eclipse.job;
18
19 import java.io.File JavaDoc;
20
21 import org.apache.forrest.eclipse.ForrestPlugin;
22 import org.apache.forrest.eclipse.preference.ForrestPreferences;
23 import org.apache.log4j.Logger;
24 import org.eclipse.core.runtime.IProgressMonitor;
25 import org.eclipse.core.runtime.IStatus;
26
27
28 /**
29  * Run a version of Forrest
30  */

31 public class ForrestBuilder extends ForrestJob {
32     /**
33      * Logger for this class
34      */

35     protected static final Logger logger = Logger.getLogger(ForrestBuilder.class);
36     /** The name of the skin to use. If null, the value in forrest.properties will be used. */
37     private String JavaDoc skinName;
38     
39     /**
40      * Create a Forrest builder that will build the default
41      * site configuration.
42      * @param workingDir - the working directory for the command
43      */

44     protected ForrestBuilder(String JavaDoc workingDir) {
45         super("Forrest Runner");
46         this.workingDir = workingDir;
47     }
48
49     /**
50      * Create a Forrest builder that will build the
51      * site using the indicated skin.
52      * @param workingDir - the working directory for the command
53      */

54     protected ForrestBuilder(String JavaDoc workingDir, String JavaDoc skinName) {
55         super("Forrest Runner");
56         this.workingDir = workingDir;
57         this.skinName = skinName;
58     }
59     /* (non-Javadoc)
60      * @see java.lang.Runnable#run()
61      */

62     public IStatus run(IProgressMonitor monitor) {
63         if (logger.isDebugEnabled()) {
64             logger.debug("run(IProgressMonitor) - start");
65         }
66         
67         IStatus status = null;
68         String JavaDoc fhome = ForrestPlugin.getDefault().getPluginPreferences()
69           .getString(ForrestPreferences.FORREST_HOME);
70         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("-Dproject.home=");
71         sb.append(workingDir);
72         sb.append(" -Dbasedir=");
73         sb.append(fhome + File.separatorChar + "main");
74         if (this.skinName != null) {
75             sb.append(" -Dproject.skin=");
76             sb.append("plain-dev");
77         }
78         sb.append(" site");
79         status = runAnt(monitor, sb.toString());
80         return status;
81     }
82     
83 }
84
Popular Tags