KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > build > AptBuilder


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * jgarms@bea.com - initial API and implementation
10  *
11  *******************************************************************************/

12 package org.eclipse.jdt.apt.core.build;
13
14 import org.eclipse.core.resources.IWorkspace;
15 import org.eclipse.core.resources.IncrementalProjectBuilder;
16 import org.eclipse.core.resources.ResourcesPlugin;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.core.runtime.NullProgressMonitor;
19 import org.eclipse.equinox.app.IApplication;
20 import org.eclipse.equinox.app.IApplicationContext;
21
22 /**
23  * Commandline entry point for building a workspace using APT.
24  * Currently cleans and then builds the entire workspace.<P>
25  *
26  * Sample commandline invocation:
27  *
28  * %ECLIPSE_HOME%/eclipsec -nosplash -application org.eclipse.jdt.apt.core.aptBuild -data %WORKSPACE%
29  *
30  * This class should not be referenced programmatically by other
31  * Java code. This class exists only for the purpose of launching
32  * the AptBuilder from the command line. The fields and methods on this
33  * class are not API.
34  */

35 public class AptBuilder implements IApplication {
36
37     /**
38      * Runs this runnable with the given application context and returns a result.
39      * The content of the args is unchecked and should conform to the expectations of
40      * the runnable being invoked. Typically this is a <code>String</code> array.
41      * Applications can return any object they like. If an <code>Integer</code> is returned
42      * it is treated as the program exit code if Eclipse is exiting.
43      *
44      * @param context the given application context passed to the application
45      * @return the return value of the application
46      * @exception Exception if there is a problem running this runnable.
47      * @see #EXIT_OK
48      * @see #EXIT_RESTART
49      * @see #EXIT_RELAUNCH
50      */

51     public Object JavaDoc start(IApplicationContext context) throws Exception JavaDoc {
52         IWorkspace workspace = ResourcesPlugin.getWorkspace();
53         IProgressMonitor progressMonitor = new SystemOutProgressMonitor();
54         workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, progressMonitor);
55         workspace.build(IncrementalProjectBuilder.FULL_BUILD, progressMonitor);
56
57         return IApplication.EXIT_OK;
58     }
59
60     public void stop() {
61         // nothing to do
62
}
63
64     /**
65      * Sends all progress to StdOut
66      */

67     private static class SystemOutProgressMonitor extends NullProgressMonitor {
68
69         public void beginTask(String JavaDoc name, int totalWork) {
70             if (name != null && name.length() > 0)
71                 System.out.println(name);
72         }
73
74         public void subTask(String JavaDoc name) {
75             if (name != null && name.length() > 0)
76                 System.out.println(name);
77         }
78     }
79
80 }
81
Popular Tags