-
Notifications
You must be signed in to change notification settings - Fork 107
/
JdtApt.java
85 lines (74 loc) · 2.69 KB
/
JdtApt.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*******************************************************************************
* Copyright (c) 2005, 2007 BEA Systems, Inc.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* jgarms@bea.com - initial API and implementation
*
*******************************************************************************/
package org.eclipse.jdt.apt.core.build;
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
import org.eclipse.jdt.apt.core.internal.build.Messages;
/**
* Ant task for invoking the commandline apt builder
*
* Sample build.xml:
*
* <project name="test_eclipse" default="build" basedir=".">
*
* <taskdef name="apt" classname="org.eclipse.jdt.apt.core.build.JdtApt"/>
*
* <target name="build">
* <apt workspace="C:\my_workspace" eclipseHome="C:\eclipse"/>
* </target>
* </project>
*/
public class JdtApt extends Java {
private static final String APP_CLASSNAME = "org.eclipse.equinox.launcher.Main"; //$NON-NLS-1$
private static final String APP_PLUGIN = "org.eclipse.jdt.apt.core.aptBuild"; //$NON-NLS-1$
private File workspace;
private File startupJar;
public void setWorkspace(File file) {
if(!file.exists()) {
throw new BuildException(Messages.JdtApt_noWorkspace + file);
}
workspace = file;
}
public void setEclipseHome(File file) {
if(!file.exists()) {
throw new BuildException(Messages.JdtApt_noEclipse + file);
}
startupJar = new File(file, "startup.jar"); //$NON-NLS-1$
if(!startupJar.exists()) {
throw new BuildException(Messages.JdtApt_noStartupJar + file);
}
}
@Override
public void execute() throws BuildException {
if(workspace == null) {
throw new BuildException("Must set a workspace"); //$NON-NLS-1$
}
if(startupJar == null) {
throw new BuildException("Must set eclipse home"); //$NON-NLS-1$
}
setFork(true);
setLogError(true);
setClasspath(new Path(null, startupJar.getAbsolutePath()));
setClassname(APP_CLASSNAME);
createArg().setValue("-noupdate"); //$NON-NLS-1$
createArg().setValue("-application"); //$NON-NLS-1$
createArg().setValue(APP_PLUGIN);
createArg().setValue("-data"); //$NON-NLS-1$
createArg().setValue(workspace.getAbsolutePath());
super.execute();
}
}