Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » eclipse plugin generator problem
eclipse plugin generator problem [message #246004] Thu, 19 July 2007 09:12 Go to next message
Eclipse UserFriend
Originally posted by: hannes.de-bondt.org

I am writing a plugin generator. the generated plugin is an editor. the
Idea is, you walk trough a wizard, and afterwards, you have a generated
plugin.
The code is generated, but now I have following problem,

"The project was not built since its build path is incomplete. Cannot
find the class file for java.lang.Object. Fix the build path then try
building this project"

what should I do, in which file can I specify the build-path?


thanx in advance.

Hannes
Re: eclipse plugin generator problem [message #246014 is a reply to message #246004] Thu, 19 July 2007 09:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------020604090908060407010402
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hannes,

Hopefully the JDT guys won't look at this and say, gross! ;-) Here's
an example of how we create a plugin project in EMF (and you're probably
missing the JRE setup):

public static IProject createEMFProject
(IPath javaSource,
URI projectLocationURI,
List<IProject> referencedProjects,
Monitor monitor,
int style,
List<?> pluginVariables)
{
IProgressMonitor progressMonitor =
BasicMonitor.toIProgressMonitor(monitor);
String projectName = javaSource.segment(0);
IProject project = null;
try
{
List<IClasspathEntry> classpathEntries = new
UniqueEList<IClasspathEntry>();

progressMonitor.beginTask("", 10);
progressMonitor.subTask
(CodeGenEcorePlugin.INSTANCE.getString
("_UI_CreatingEMFProject_message",
new Object [] { projectName, projectLocationURI !=
null ? projectLocationURI.toString() : projectName }));
IWorkspace workspace = ResourcesPlugin.getWorkspace();
project = workspace.getRoot().getProject(projectName);

// Clean up any old project information.
//
if (!project.exists())
{
URI location = projectLocationURI;
if (location == null)
{
location =
URI.createFileURI(workspace.getRoot().getLocation().append(p rojectName).toOSString());
}
location = location.appendSegment(".project");
File projectFile = new File(location.toString());
if (projectFile.exists())
{
projectFile.renameTo(new File(location.toString() +
".old"));
}
}

IJavaProject javaProject = JavaCore.create(project);
IProjectDescription projectDescription = null;
if (!project.exists())
{
projectDescription =
ResourcesPlugin.getWorkspace().newProjectDescription(project Name);
if (projectLocationURI != null)
{
projectDescription.setLocationURI(new
java.net.URI(projectLocationURI.toString()));
}
project.create(projectDescription, new
SubProgressMonitor(progressMonitor, 1));
}
else
{
projectDescription = project.getDescription();

classpathEntries.addAll(Arrays.asList(javaProject.getRawClas spath()));
}

boolean isInitiallyEmpty = classpathEntries.isEmpty();

{
if (referencedProjects.size() != 0 && (style &
(EMF_PLUGIN_PROJECT_STYLE | EMF_EMPTY_PROJECT_STYLE)) == 0)
{
projectDescription.setReferencedProjects
(referencedProjects.toArray(new
IProject[referencedProjects.size()]));
for (IProject referencedProject : referencedProjects)
{
IClasspathEntry referencedProjectClasspathEntry =
JavaCore.newProjectEntry(referencedProject.getFullPath());
classpathEntries.add(referencedProjectClasspathEntry);
}
}

String [] natureIds = projectDescription.getNatureIds();
if (natureIds == null)
{
natureIds = new String [] { JavaCore.NATURE_ID };
}
else
{
boolean hasJavaNature = false;
boolean hasPDENature = false;
for (int i = 0; i < natureIds.length; ++i)
{
if (JavaCore.NATURE_ID.equals(natureIds[i]))
{
hasJavaNature = true;
}
if ("org.eclipse.pde.PluginNature".equals(natureIds[i]))
{
hasPDENature = true;
}
}
if (!hasJavaNature)
{
String [] oldNatureIds = natureIds;
natureIds = new String [oldNatureIds.length + 1];
System.arraycopy(oldNatureIds, 0, natureIds, 0,
oldNatureIds.length);
natureIds[oldNatureIds.length] = JavaCore.NATURE_ID;
}
if (!hasPDENature)
{
String [] oldNatureIds = natureIds;
natureIds = new String [oldNatureIds.length + 1];
System.arraycopy(oldNatureIds, 0, natureIds, 0,
oldNatureIds.length);
natureIds[oldNatureIds.length] =
"org.eclipse.pde.PluginNature";
}
}
projectDescription.setNatureIds(natureIds);

ICommand [] builders = projectDescription.getBuildSpec();
if (builders == null)
{
builders = new ICommand [0];
}
boolean hasManifestBuilder = false;
boolean hasSchemaBuilder = false;
for (int i = 0; i < builders.length; ++i)
{
if
("org.eclipse.pde.ManifestBuilder".equals(builders[i].getBuilderName()))
{
hasManifestBuilder = true;
}
if
("org.eclipse.pde.SchemaBuilder".equals(builders[i].getBuilderName()))
{
hasSchemaBuilder = true;
}
}
if (!hasManifestBuilder)
{
ICommand [] oldBuilders = builders;
builders = new ICommand [oldBuilders.length + 1];
System.arraycopy(oldBuilders, 0, builders, 0,
oldBuilders.length);
builders[oldBuilders.length] =
projectDescription.newCommand();

builders[oldBuilders.length].setBuilderName("org.eclipse.pde.ManifestBuilder ");
}
if (!hasSchemaBuilder)
{
ICommand [] oldBuilders = builders;
builders = new ICommand [oldBuilders.length + 1];
System.arraycopy(oldBuilders, 0, builders, 0,
oldBuilders.length);
builders[oldBuilders.length] =
projectDescription.newCommand();

builders[oldBuilders.length].setBuilderName("org.eclipse.pde.SchemaBuilder ");
}
projectDescription.setBuildSpec(builders);

project.open(new SubProgressMonitor(progressMonitor, 1));
project.setDescription(projectDescription, new
SubProgressMonitor(progressMonitor, 1));

IContainer sourceContainer = project;
if (javaSource.segmentCount() > 1)
{
sourceContainer =
project.getFolder(javaSource.removeFirstSegments(1).makeAbso lute());
if (!sourceContainer.exists())
{
((IFolder)sourceContainer).create(false, true, new
SubProgressMonitor(progressMonitor, 1));
}
}

if (isInitiallyEmpty)
{
IClasspathEntry sourceClasspathEntry =
JavaCore.newSourceEntry(javaSource);
for (Iterator<IClasspathEntry> i =
classpathEntries.iterator(); i.hasNext(); )
{
IClasspathEntry classpathEntry = i.next();
if (classpathEntry.getPath().isPrefixOf(javaSource))
{
i.remove();
}
}
classpathEntries.add(0, sourceClasspathEntry);

IClasspathEntry jreClasspathEntry =
JavaCore.newVariableEntry
(new Path(JavaRuntime.JRELIB_VARIABLE), new
Path(JavaRuntime.JRESRC_VARIABLE), new
Path(JavaRuntime.JRESRCROOT_VARIABLE));
for (Iterator<IClasspathEntry> i =
classpathEntries.iterator(); i.hasNext(); )
{
IClasspathEntry classpathEntry = i.next();
if
(classpathEntry.getPath().isPrefixOf(jreClasspathEntry.getPa th()))
{
i.remove();
}
}

String jreContainer = JavaRuntime.JRE_CONTAINER;
String complianceLevel =
CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project);
if ("1.5".equals(complianceLevel))
{
jreContainer +=
" /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J 2SE-1.5 ";
}
else if ("1.6".equals(complianceLevel))
{
jreContainer +=
" /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J avaSE-1.6 ";
}
classpathEntries.add(JavaCore.newContainerEntry(new
Path(jreContainer)));
}

if ((style & EMF_EMPTY_PROJECT_STYLE) == 0)
{
if ((style & EMF_PLUGIN_PROJECT_STYLE) != 0)
{
classpathEntries.add(JavaCore.newContainerEntry(new
Path("org.eclipse.pde.core.requiredPlugins")));

// Remove variables since the plugin.xml should
provide the complete path information.
//
for (Iterator<IClasspathEntry> i =
classpathEntries.iterator(); i.hasNext(); )
{
IClasspathEntry classpathEntry = i.next();
if (classpathEntry.getEntryKind() ==
IClasspathEntry.CPE_VARIABLE &&

!JavaRuntime.JRELIB_VARIABLE.equals(classpathEntry.getPath() .toString())
||
classpathEntry.getEntryKind() ==
IClasspathEntry.CPE_PROJECT)
{
i.remove();
}
}
}
else
{

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_CORE_RUNTIME", "org.eclipse.core.runtime");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_CORE_RESOURCES", "org.eclipse.core.resources");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_COMMON", "org.eclipse.emf.common");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_ECORE", "org.eclipse.emf.ecore");

if ((style & EMF_XML_PROJECT_STYLE) != 0)
{

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
}

if ((style & EMF_MODEL_PROJECT_STYLE) == 0)
{

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_EDIT", "org.eclipse.emf.edit");

if ((style & EMF_EDIT_PROJECT_STYLE) == 0)
{

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_SWT", "org.eclipse.swt");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_JFACE", "org.eclipse.jface");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_VIEWS", "org.eclipse.ui.views");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_EDITORS", "org.eclipse.ui.editors");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_IDE", "org.eclipse.ui.ide");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_WORKBENCH", "org.eclipse.ui.workbench");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_COMMON_UI", "org.eclipse.emf.common.ui");

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_EDIT_UI", "org.eclipse.emf.edit.ui");
if ((style & EMF_XML_PROJECT_STYLE) == 0)
{

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
}
}
}

if ((style & EMF_TESTS_PROJECT_STYLE) != 0)
{

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"JUNIT", "org.junit");
}

if (pluginVariables != null)
{
for (Iterator<?> i = pluginVariables.iterator();
i.hasNext(); )
{
Object variable = i.next();
if (variable instanceof IClasspathEntry)
{
classpathEntries.add((IClasspathEntry)variable);
}
else if (variable instanceof String)
{
String pluginVariable = (String)variable;
String name;
String id;
int index = pluginVariable.indexOf("=");
if (index == -1)
{
name =
pluginVariable.replace('.','_').toUpperCase();
id = pluginVariable;
}
else
{
name = pluginVariable.substring(0, index);
id = pluginVariable.substring(index + 1);
}

CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries , name, id);
}
}
}
}
}

javaProject.setRawClasspath
(classpathEntries.toArray(new
IClasspathEntry[classpathEntries.size()]),
new SubProgressMonitor(progressMonitor, 1));
}

if (isInitiallyEmpty)
{
javaProject.setOutputLocation(new Path("/" +
javaSource.segment(0) + "/bin"), new
SubProgressMonitor(progressMonitor, 1));
}
}
catch (Exception exception)
{
exception.printStackTrace();
CodeGenEcorePlugin.INSTANCE.log(exception);
}
finally
{
progressMonitor.done();
}

return project;
}




hannes wrote:
> I am writing a plugin generator. the generated plugin is an editor.
> the Idea is, you walk trough a wizard, and afterwards, you have a
> generated plugin.
> The code is generated, but now I have following problem,
>
> "The project was not built since its build path is incomplete. Cannot
> find the class file for java.lang.Object. Fix the build path then try
> building this project"
>
> what should I do, in which file can I specify the build-path?
>
>
> thanx in advance.
>
> Hannes


--------------020604090908060407010402
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hannes,<br>
<br>
Hopefully the JDT guys won't look at this and say, gross!&nbsp; ;-)&nbsp; Here's
an example of how we create a plugin project in EMF (and you're
probably missing the JRE setup):<br>
<blockquote><small>&nbsp;&nbsp;&nbsp; public static IProject createEMFProject</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (IPath javaSource,</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; URI projectLocationURI,</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;IProject&gt; referencedProjects,</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Monitor monitor,</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int style,</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;?&gt; pluginVariables)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IProgressMonitor progressMonitor =
BasicMonitor.toIProgressMonitor(monitor);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String projectName = javaSource.segment(0);</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IProject project = null;</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; List&lt;IClasspathEntry&gt; classpathEntries = new
UniqueEList&lt;IClasspathEntry&gt;();</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; progressMonitor.beginTask("", 10);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; progressMonitor.subTask</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (CodeGenEcorePlugin.INSTANCE.getString</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ("_UI_CreatingEMFProject_message", </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; new Object [] { projectName, projectLocationURI
!= null ? projectLocationURI.toString() : projectName }));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IWorkspace workspace = ResourcesPlugin.getWorkspace();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; project = workspace.getRoot().getProject(projectName);</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Clean up any old project information.</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; //</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (!project.exists())</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; URI location = projectLocationURI;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (location == null)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location =
URI.createFileURI(workspace.getRoot().getLocation().append(p rojectName).toOSString()); </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; location = location.appendSegment(".project");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; File projectFile = new File(location.toString());</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (projectFile.exists())</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; projectFile.renameTo(new File(location.toString()
+ ".old"));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IJavaProject javaProject = JavaCore.create(project);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IProjectDescription projectDescription = null;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (!project.exists())</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; projectDescription =
ResourcesPlugin.getWorkspace().newProjectDescription(project Name); </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (projectLocationURI != null)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; projectDescription.setLocationURI(new
java.net.URI(projectLocationURI.toString()));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; project.create(projectDescription, new
SubProgressMonitor(progressMonitor, 1));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; projectDescription = project.getDescription();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
classpathEntries.addAll(Arrays.asList(javaProject.getRawClas spath())); </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; boolean isInitiallyEmpty = classpathEntries.isEmpty();</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (referencedProjects.size() != 0 &amp;&amp; (style
&amp; (EMF_PLUGIN_PROJECT_STYLE | EMF_EMPTY_PROJECT_STYLE)) == 0)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; projectDescription.setReferencedProjects</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; (referencedProjects.toArray(new
IProject[referencedProjects.size()]));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (IProject referencedProject :
referencedProjects)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IClasspathEntry referencedProjectClasspathEntry
= JavaCore.newProjectEntry(referencedProject.getFullPath());</small ><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
classpathEntries.add(referencedProjectClasspathEntry);</small ><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String [] natureIds =
projectDescription.getNatureIds();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (natureIds == null)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; natureIds = new String [] { JavaCore.NATURE_ID };</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boolean hasJavaNature = false;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boolean hasPDENature = false;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; natureIds.length; ++i)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (JavaCore.NATURE_ID.equals(natureIds[i]))</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; hasJavaNature = true;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if
("org.eclipse.pde.PluginNature".equals(natureIds[i]))</small ><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; hasPDENature = true;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!hasJavaNature)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; String [] oldNatureIds = natureIds;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; natureIds = new String [oldNatureIds.length + 1];</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; System.arraycopy(oldNatureIds, 0, natureIds, 0,
oldNatureIds.length);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; natureIds[oldNatureIds.length] =
JavaCore.NATURE_ID;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!hasPDENature)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; String [] oldNatureIds = natureIds;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; natureIds = new String [oldNatureIds.length + 1];</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; System.arraycopy(oldNatureIds, 0, natureIds, 0,
oldNatureIds.length);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; natureIds[oldNatureIds.length] =
"org.eclipse.pde.PluginNature";</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; projectDescription.setNatureIds(natureIds);</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ICommand [] builders =
projectDescription.getBuildSpec();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (builders == null)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builders = new ICommand [0];</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; boolean hasManifestBuilder = false;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; boolean hasSchemaBuilder = false;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; builders.length; ++i)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
("org.eclipse.pde.ManifestBuilder".equals(builders[i].getBuilderName())) </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; hasManifestBuilder = true;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
("org.eclipse.pde.SchemaBuilder".equals(builders[i].getBuilderName())) </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; hasSchemaBuilder = true;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!hasManifestBuilder)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICommand [] oldBuilders = builders;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builders = new ICommand [oldBuilders.length + 1];</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.arraycopy(oldBuilders, 0, builders, 0,
oldBuilders.length);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builders[oldBuilders.length] =
projectDescription.newCommand();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
builders[oldBuilders.length].setBuilderName("org.eclipse.pde.ManifestBuilder ");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!hasSchemaBuilder)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICommand [] oldBuilders = builders;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builders = new ICommand [oldBuilders.length + 1];</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.arraycopy(oldBuilders, 0, builders, 0,
oldBuilders.length);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; builders[oldBuilders.length] =
projectDescription.newCommand();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
builders[oldBuilders.length].setBuilderName("org.eclipse.pde.SchemaBuilder ");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; projectDescription.setBuildSpec(builders);</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; project.open(new SubProgressMonitor(progressMonitor,
1));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; project.setDescription(projectDescription, new
SubProgressMonitor(progressMonitor, 1));</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IContainer sourceContainer = project;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (javaSource.segmentCount() &gt; 1)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sourceContainer =
project.getFolder(javaSource.removeFirstSegments(1).makeAbso lute()); </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!sourceContainer.exists())</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ((IFolder)sourceContainer).create(false, true,
new SubProgressMonitor(progressMonitor, 1));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (isInitiallyEmpty)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IClasspathEntry sourceClasspathEntry = </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; JavaCore.newSourceEntry(javaSource);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Iterator&lt;IClasspathEntry&gt; i =
classpathEntries.iterator(); i.hasNext(); )</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IClasspathEntry classpathEntry = i.next();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if
(classpathEntry.getPath().isPrefixOf(javaSource))</small><br >
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; i.remove();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; classpathEntries.add(0, sourceClasspathEntry);</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IClasspathEntry jreClasspathEntry =</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; JavaCore.newVariableEntry</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (new Path(JavaRuntime.JRELIB_VARIABLE), new
Path(JavaRuntime.JRESRC_VARIABLE), new
Path(JavaRuntime.JRESRCROOT_VARIABLE));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (Iterator&lt;IClasspathEntry&gt; i =
classpathEntries.iterator(); i.hasNext(); )</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; IClasspathEntry classpathEntry = i.next();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if
(classpathEntry.getPath().isPrefixOf(jreClasspathEntry.getPa th())) </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; i.remove();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String jreContainer = JavaRuntime.JRE_CONTAINER;</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String complianceLevel =
CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project);</small ><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ("1.5".equals(complianceLevel))</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; jreContainer +=
" /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J 2SE-1.5 ";</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if ("1.6".equals(complianceLevel))</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; jreContainer +=
" /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J avaSE-1.6 ";</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
classpathEntries.add(JavaCore.newContainerEntry(new
Path(jreContainer)));</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ((style &amp; EMF_EMPTY_PROJECT_STYLE) == 0)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((style &amp; EMF_PLUGIN_PROJECT_STYLE) != 0)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
classpathEntries.add(JavaCore.newContainerEntry(new
Path("org.eclipse.pde.core.requiredPlugins")));</small><br >
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Remove variables since the plugin.xml should
provide the complete path information.</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; //</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; for (Iterator&lt;IClasspathEntry&gt; i =
classpathEntries.iterator(); i.hasNext(); )</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IClasspathEntry classpathEntry = i.next();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (classpathEntry.getEntryKind() ==
IClasspathEntry.CPE_VARIABLE &amp;&amp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
!JavaRuntime.JRELIB_VARIABLE.equals(classpathEntry.getPath() .toString())
||</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; classpathEntry.getEntryKind() ==
IClasspathEntry.CPE_PROJECT)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i.remove();</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_CORE_RUNTIME", "org.eclipse.core.runtime");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_CORE_RESOURCES", "org.eclipse.core.resources");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_COMMON", "org.eclipse.emf.common");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_ECORE", "org.eclipse.emf.ecore");</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if ((style &amp; EMF_XML_PROJECT_STYLE) != 0)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if ((style &amp; EMF_MODEL_PROJECT_STYLE) == 0)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_EDIT", "org.eclipse.emf.edit");</small><br>
<small>&nbsp; </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ((style &amp; EMF_EDIT_PROJECT_STYLE) == 0)</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_SWT", "org.eclipse.swt");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_JFACE", "org.eclipse.jface");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_VIEWS", "org.eclipse.ui.views");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_EDITORS", "org.eclipse.ui.editors");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_IDE", "org.eclipse.ui.ide");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"ECLIPSE_UI_WORKBENCH", "org.eclipse.ui.workbench");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
"EMF_COMMON_UI", "org.eclipse.emf.common.ui");</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CodeGenUtil.EclipseUtil.ad
Re: eclipse plugin generator problem [message #246127 is a reply to message #246014] Wed, 25 July 2007 08:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hannes.de-bondt.org

I tried to understand the code, but is was very dificult.

I allready had a dirty solution, without the EMF. The deadline for this
project is way to short to chance to EMF now. so I will have to do it
quick and dirty.

But the problem with the wrong build path still exists.
Is there someone who can tell me where (so in which file) I can adapt
the build path.

Thanx in advance

Hannes


Ed Merks wrote:
> Hannes,
>
> Hopefully the JDT guys won't look at this and say, gross! ;-) Here's
> an example of how we create a plugin project in EMF (and you're probably
> missing the JRE setup):
>
> public static IProject createEMFProject
> (IPath javaSource,
> URI projectLocationURI,
> List<IProject> referencedProjects,
> Monitor monitor,
> int style,
> List<?> pluginVariables)
> {
> IProgressMonitor progressMonitor =
> BasicMonitor.toIProgressMonitor(monitor);
> String projectName = javaSource.segment(0);
> IProject project = null;
> try
> {
> List<IClasspathEntry> classpathEntries = new
> UniqueEList<IClasspathEntry>();
>
> progressMonitor.beginTask("", 10);
> progressMonitor.subTask
> (CodeGenEcorePlugin.INSTANCE.getString
> ("_UI_CreatingEMFProject_message",
> new Object [] { projectName, projectLocationURI !=
> null ? projectLocationURI.toString() : projectName }));
> IWorkspace workspace = ResourcesPlugin.getWorkspace();
> project = workspace.getRoot().getProject(projectName);
>
> // Clean up any old project information.
> //
> if (!project.exists())
> {
> URI location = projectLocationURI;
> if (location == null)
> {
> location =
> URI.createFileURI(workspace.getRoot().getLocation().append(p rojectName).toOSString());
> }
> location = location.appendSegment(".project");
> File projectFile = new File(location.toString());
> if (projectFile.exists())
> {
> projectFile.renameTo(new File(location.toString() +
> ".old"));
> }
> }
>
> IJavaProject javaProject = JavaCore.create(project);
> IProjectDescription projectDescription = null;
> if (!project.exists())
> {
> projectDescription =
> ResourcesPlugin.getWorkspace().newProjectDescription(project Name);
> if (projectLocationURI != null)
> {
> projectDescription.setLocationURI(new
> java.net.URI(projectLocationURI.toString()));
> }
> project.create(projectDescription, new
> SubProgressMonitor(progressMonitor, 1));
> }
> else
> {
> projectDescription = project.getDescription();
>
> classpathEntries.addAll(Arrays.asList(javaProject.getRawClas spath()));
> }
>
> boolean isInitiallyEmpty = classpathEntries.isEmpty();
>
> {
> if (referencedProjects.size() != 0 && (style &
> (EMF_PLUGIN_PROJECT_STYLE | EMF_EMPTY_PROJECT_STYLE)) == 0)
> {
> projectDescription.setReferencedProjects
> (referencedProjects.toArray(new
> IProject[referencedProjects.size()]));
> for (IProject referencedProject : referencedProjects)
> {
> IClasspathEntry referencedProjectClasspathEntry =
> JavaCore.newProjectEntry(referencedProject.getFullPath());
> classpathEntries.add(referencedProjectClasspathEntry);
> }
> }
>
> String [] natureIds = projectDescription.getNatureIds();
> if (natureIds == null)
> {
> natureIds = new String [] { JavaCore.NATURE_ID };
> }
> else
> {
> boolean hasJavaNature = false;
> boolean hasPDENature = false;
> for (int i = 0; i < natureIds.length; ++i)
> {
> if (JavaCore.NATURE_ID.equals(natureIds[i]))
> {
> hasJavaNature = true;
> }
> if ("org.eclipse.pde.PluginNature".equals(natureIds[i]))
> {
> hasPDENature = true;
> }
> }
> if (!hasJavaNature)
> {
> String [] oldNatureIds = natureIds;
> natureIds = new String [oldNatureIds.length + 1];
> System.arraycopy(oldNatureIds, 0, natureIds, 0,
> oldNatureIds.length);
> natureIds[oldNatureIds.length] = JavaCore.NATURE_ID;
> }
> if (!hasPDENature)
> {
> String [] oldNatureIds = natureIds;
> natureIds = new String [oldNatureIds.length + 1];
> System.arraycopy(oldNatureIds, 0, natureIds, 0,
> oldNatureIds.length);
> natureIds[oldNatureIds.length] =
> "org.eclipse.pde.PluginNature";
> }
> }
> projectDescription.setNatureIds(natureIds);
>
> ICommand [] builders = projectDescription.getBuildSpec();
> if (builders == null)
> {
> builders = new ICommand [0];
> }
> boolean hasManifestBuilder = false;
> boolean hasSchemaBuilder = false;
> for (int i = 0; i < builders.length; ++i)
> {
> if
> ("org.eclipse.pde.ManifestBuilder".equals(builders[i].getBuilderName()))
> {
> hasManifestBuilder = true;
> }
> if
> ("org.eclipse.pde.SchemaBuilder".equals(builders[i].getBuilderName()))
> {
> hasSchemaBuilder = true;
> }
> }
> if (!hasManifestBuilder)
> {
> ICommand [] oldBuilders = builders;
> builders = new ICommand [oldBuilders.length + 1];
> System.arraycopy(oldBuilders, 0, builders, 0,
> oldBuilders.length);
> builders[oldBuilders.length] =
> projectDescription.newCommand();
>
> builders[oldBuilders.length].setBuilderName("org.eclipse.pde.ManifestBuilder ");
> }
> if (!hasSchemaBuilder)
> {
> ICommand [] oldBuilders = builders;
> builders = new ICommand [oldBuilders.length + 1];
> System.arraycopy(oldBuilders, 0, builders, 0,
> oldBuilders.length);
> builders[oldBuilders.length] =
> projectDescription.newCommand();
>
> builders[oldBuilders.length].setBuilderName("org.eclipse.pde.SchemaBuilder ");
> }
> projectDescription.setBuildSpec(builders);
>
> project.open(new SubProgressMonitor(progressMonitor, 1));
> project.setDescription(projectDescription, new
> SubProgressMonitor(progressMonitor, 1));
>
> IContainer sourceContainer = project;
> if (javaSource.segmentCount() > 1)
> {
> sourceContainer =
> project.getFolder(javaSource.removeFirstSegments(1).makeAbso lute());
> if (!sourceContainer.exists())
> {
> ((IFolder)sourceContainer).create(false, true, new
> SubProgressMonitor(progressMonitor, 1));
> }
> }
>
> if (isInitiallyEmpty)
> {
> IClasspathEntry sourceClasspathEntry =
> JavaCore.newSourceEntry(javaSource);
> for (Iterator<IClasspathEntry> i =
> classpathEntries.iterator(); i.hasNext(); )
> {
> IClasspathEntry classpathEntry = i.next();
> if (classpathEntry.getPath().isPrefixOf(javaSource))
> {
> i.remove();
> }
> }
> classpathEntries.add(0, sourceClasspathEntry);
>
> IClasspathEntry jreClasspathEntry =
> JavaCore.newVariableEntry
> (new Path(JavaRuntime.JRELIB_VARIABLE), new
> Path(JavaRuntime.JRESRC_VARIABLE), new
> Path(JavaRuntime.JRESRCROOT_VARIABLE));
> for (Iterator<IClasspathEntry> i =
> classpathEntries.iterator(); i.hasNext(); )
> {
> IClasspathEntry classpathEntry = i.next();
> if
> (classpathEntry.getPath().isPrefixOf(jreClasspathEntry.getPa th()))
> {
> i.remove();
> }
> }
>
> String jreContainer = JavaRuntime.JRE_CONTAINER;
> String complianceLevel =
> CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project);
> if ("1.5".equals(complianceLevel))
> {
> jreContainer +=
> " /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J 2SE-1.5 ";
> }
> else if ("1.6".equals(complianceLevel))
> {
> jreContainer +=
> " /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J avaSE-1.6 ";
> }
> classpathEntries.add(JavaCore.newContainerEntry(new
> Path(jreContainer)));
> }
>
> if ((style & EMF_EMPTY_PROJECT_STYLE) == 0)
> {
> if ((style & EMF_PLUGIN_PROJECT_STYLE) != 0)
> {
> classpathEntries.add(JavaCore.newContainerEntry(new
> Path("org.eclipse.pde.core.requiredPlugins")));
>
> // Remove variables since the plugin.xml should
> provide the complete path information.
> //
> for (Iterator<IClasspathEntry> i =
> classpathEntries.iterator(); i.hasNext(); )
> {
> IClasspathEntry classpathEntry = i.next();
> if (classpathEntry.getEntryKind() ==
> IClasspathEntry.CPE_VARIABLE &&
>
> !JavaRuntime.JRELIB_VARIABLE.equals(classpathEntry.getPath() .toString())
> ||
> classpathEntry.getEntryKind() ==
> IClasspathEntry.CPE_PROJECT)
> {
> i.remove();
> }
> }
> }
> else
> {
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_CORE_RUNTIME", "org.eclipse.core.runtime");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_CORE_RESOURCES", "org.eclipse.core.resources");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "EMF_COMMON", "org.eclipse.emf.common");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "EMF_ECORE", "org.eclipse.emf.ecore");
>
> if ((style & EMF_XML_PROJECT_STYLE) != 0)
> {
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
> }
>
> if ((style & EMF_MODEL_PROJECT_STYLE) == 0)
> {
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "EMF_EDIT", "org.eclipse.emf.edit");
>
> if ((style & EMF_EDIT_PROJECT_STYLE) == 0)
> {
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_SWT", "org.eclipse.swt");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_JFACE", "org.eclipse.jface");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_UI_VIEWS", "org.eclipse.ui.views");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_UI_EDITORS", "org.eclipse.ui.editors");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_UI_IDE", "org.eclipse.ui.ide");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "ECLIPSE_UI_WORKBENCH", "org.eclipse.ui.workbench");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "EMF_COMMON_UI", "org.eclipse.emf.common.ui");
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "EMF_EDIT_UI", "org.eclipse.emf.edit.ui");
> if ((style & EMF_XML_PROJECT_STYLE) == 0)
> {
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
> }
> }
> }
>
> if ((style & EMF_TESTS_PROJECT_STYLE) != 0)
> {
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
> "JUNIT", "org.junit");
> }
>
> if (pluginVariables != null)
> {
> for (Iterator<?> i = pluginVariables.iterator();
> i.hasNext(); )
> {
> Object variable = i.next();
> if (variable instanceof IClasspathEntry)
> {
> classpathEntries.add((IClasspathEntry)variable);
> }
> else if (variable instanceof String)
> {
> String pluginVariable = (String)variable;
> String name;
> String id;
> int index = pluginVariable.indexOf("=");
> if (index == -1)
> {
> name =
> pluginVariable.replace('.','_').toUpperCase();
> id = pluginVariable;
> }
> else
> {
> name = pluginVariable.substring(0, index);
> id = pluginVariable.substring(index + 1);
> }
>
> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries , name, id);
> }
> }
> }
> }
> }
>
> javaProject.setRawClasspath
> (classpathEntries.toArray(new
> IClasspathEntry[classpathEntries.size()]),
> new SubProgressMonitor(progressMonitor, 1));
> }
>
> if (isInitiallyEmpty)
> {
> javaProject.setOutputLocation(new Path("/" +
> javaSource.segment(0) + "/bin"), new
> SubProgressMonitor(progressMonitor, 1));
> }
> }
> catch (Exception exception)
> {
> exception.printStackTrace();
> CodeGenEcorePlugin.INSTANCE.log(exception);
> }
> finally
> {
> progressMonitor.done();
> }
>
> return project;
> }
>
>
>
>
> hannes wrote:
>> I am writing a plugin generator. the generated plugin is an editor.
>> the Idea is, you walk trough a wizard, and afterwards, you have a
>> generated plugin.
>> The code is generated, but now I have following problem,
>>
>> "The project was not built since its build path is incomplete. Cannot
>> find the class file for java.lang.Object. Fix the build path then try
>> building this project"
>>
>> what should I do, in which file can I specify the build-path?
>>
>>
>> thanx in advance.
>>
>> Hannes
>
Re: eclipse plugin generator problem [message #246135 is a reply to message #246127] Wed, 25 July 2007 09:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Hannes,

I wasn't trying to suggest you should use EMF, but rather providing a
working example. If you installed EMF you could set breakpoints and
watch the behavior. The most important part of the example below for
you sounds like the setting of the JRE into the classapth and finally
calling setRawClasspath on the Java project. So look closely at the
..classpath file in your result verses a working project and keep in mind
that you just set a good classpath with the right entries to produce
your desired result.


hannes wrote:
> I tried to understand the code, but is was very dificult.
>
> I allready had a dirty solution, without the EMF. The deadline for
> this project is way to short to chance to EMF now. so I will have to
> do it quick and dirty.
>
> But the problem with the wrong build path still exists.
> Is there someone who can tell me where (so in which file) I can adapt
> the build path.
>
> Thanx in advance
>
> Hannes
>
>
> Ed Merks wrote:
>> Hannes,
>>
>> Hopefully the JDT guys won't look at this and say, gross! ;-)
>> Here's an example of how we create a plugin project in EMF (and
>> you're probably missing the JRE setup):
>>
>> public static IProject createEMFProject
>> (IPath javaSource,
>> URI projectLocationURI,
>> List<IProject> referencedProjects,
>> Monitor monitor,
>> int style,
>> List<?> pluginVariables)
>> {
>> IProgressMonitor progressMonitor =
>> BasicMonitor.toIProgressMonitor(monitor);
>> String projectName = javaSource.segment(0);
>> IProject project = null;
>> try
>> {
>> List<IClasspathEntry> classpathEntries = new
>> UniqueEList<IClasspathEntry>();
>> progressMonitor.beginTask("", 10);
>> progressMonitor.subTask
>> (CodeGenEcorePlugin.INSTANCE.getString
>> ("_UI_CreatingEMFProject_message",
>> new Object [] { projectName, projectLocationURI !=
>> null ? projectLocationURI.toString() : projectName }));
>> IWorkspace workspace = ResourcesPlugin.getWorkspace();
>> project = workspace.getRoot().getProject(projectName);
>> // Clean up any old project information.
>> //
>> if (!project.exists())
>> {
>> URI location = projectLocationURI;
>> if (location == null)
>> {
>> location =
>>
>> URI.createFileURI(workspace.getRoot().getLocation().append(p rojectName).toOSString());
>>
>> }
>> location = location.appendSegment(".project");
>> File projectFile = new File(location.toString());
>> if (projectFile.exists())
>> {
>> projectFile.renameTo(new File(location.toString() +
>> ".old"));
>> }
>> }
>> IJavaProject javaProject = JavaCore.create(project);
>> IProjectDescription projectDescription = null;
>> if (!project.exists())
>> {
>> projectDescription =
>> ResourcesPlugin.getWorkspace().newProjectDescription(project Name);
>> if (projectLocationURI != null)
>> {
>> projectDescription.setLocationURI(new
>> java.net.URI(projectLocationURI.toString()));
>> }
>> project.create(projectDescription, new
>> SubProgressMonitor(progressMonitor, 1));
>> }
>> else
>> {
>> projectDescription = project.getDescription();
>>
>> classpathEntries.addAll(Arrays.asList(javaProject.getRawClas spath()));
>> }
>> boolean isInitiallyEmpty = classpathEntries.isEmpty();
>> {
>> if (referencedProjects.size() != 0 && (style &
>> (EMF_PLUGIN_PROJECT_STYLE | EMF_EMPTY_PROJECT_STYLE)) == 0)
>> {
>> projectDescription.setReferencedProjects
>> (referencedProjects.toArray(new
>> IProject[referencedProjects.size()]));
>> for (IProject referencedProject : referencedProjects)
>> {
>> IClasspathEntry referencedProjectClasspathEntry =
>> JavaCore.newProjectEntry(referencedProject.getFullPath());
>> classpathEntries.add(referencedProjectClasspathEntry);
>> }
>> }
>> String [] natureIds =
>> projectDescription.getNatureIds();
>> if (natureIds == null)
>> {
>> natureIds = new String [] { JavaCore.NATURE_ID };
>> }
>> else
>> {
>> boolean hasJavaNature = false;
>> boolean hasPDENature = false;
>> for (int i = 0; i < natureIds.length; ++i)
>> {
>> if (JavaCore.NATURE_ID.equals(natureIds[i]))
>> {
>> hasJavaNature = true;
>> }
>> if
>> ("org.eclipse.pde.PluginNature".equals(natureIds[i]))
>> {
>> hasPDENature = true;
>> }
>> }
>> if (!hasJavaNature)
>> {
>> String [] oldNatureIds = natureIds;
>> natureIds = new String [oldNatureIds.length + 1];
>> System.arraycopy(oldNatureIds, 0, natureIds, 0,
>> oldNatureIds.length);
>> natureIds[oldNatureIds.length] = JavaCore.NATURE_ID;
>> }
>> if (!hasPDENature)
>> {
>> String [] oldNatureIds = natureIds;
>> natureIds = new String [oldNatureIds.length + 1];
>> System.arraycopy(oldNatureIds, 0, natureIds, 0,
>> oldNatureIds.length);
>> natureIds[oldNatureIds.length] =
>> "org.eclipse.pde.PluginNature";
>> }
>> }
>> projectDescription.setNatureIds(natureIds);
>> ICommand [] builders =
>> projectDescription.getBuildSpec();
>> if (builders == null)
>> {
>> builders = new ICommand [0];
>> }
>> boolean hasManifestBuilder = false;
>> boolean hasSchemaBuilder = false;
>> for (int i = 0; i < builders.length; ++i)
>> {
>> if
>>
>> ("org.eclipse.pde.ManifestBuilder".equals(builders[i].getBuilderName()))
>> {
>> hasManifestBuilder = true;
>> }
>> if
>>
>> ("org.eclipse.pde.SchemaBuilder".equals(builders[i].getBuilderName()))
>> {
>> hasSchemaBuilder = true;
>> }
>> }
>> if (!hasManifestBuilder)
>> {
>> ICommand [] oldBuilders = builders;
>> builders = new ICommand [oldBuilders.length + 1];
>> System.arraycopy(oldBuilders, 0, builders, 0,
>> oldBuilders.length);
>> builders[oldBuilders.length] =
>> projectDescription.newCommand();
>>
>> builders[oldBuilders.length].setBuilderName("org.eclipse.pde.ManifestBuilder ");
>>
>> }
>> if (!hasSchemaBuilder)
>> {
>> ICommand [] oldBuilders = builders;
>> builders = new ICommand [oldBuilders.length + 1];
>> System.arraycopy(oldBuilders, 0, builders, 0,
>> oldBuilders.length);
>> builders[oldBuilders.length] =
>> projectDescription.newCommand();
>>
>> builders[oldBuilders.length].setBuilderName("org.eclipse.pde.SchemaBuilder ");
>>
>> }
>> projectDescription.setBuildSpec(builders);
>> project.open(new
>> SubProgressMonitor(progressMonitor, 1));
>> project.setDescription(projectDescription, new
>> SubProgressMonitor(progressMonitor, 1));
>> IContainer sourceContainer = project;
>> if (javaSource.segmentCount() > 1)
>> {
>> sourceContainer =
>> project.getFolder(javaSource.removeFirstSegments(1).makeAbso lute());
>> if (!sourceContainer.exists())
>> {
>> ((IFolder)sourceContainer).create(false, true, new
>> SubProgressMonitor(progressMonitor, 1));
>> }
>> }
>> if (isInitiallyEmpty)
>> {
>> IClasspathEntry sourceClasspathEntry =
>> JavaCore.newSourceEntry(javaSource);
>> for (Iterator<IClasspathEntry> i =
>> classpathEntries.iterator(); i.hasNext(); )
>> {
>> IClasspathEntry classpathEntry = i.next();
>> if (classpathEntry.getPath().isPrefixOf(javaSource))
>> {
>> i.remove();
>> }
>> }
>> classpathEntries.add(0, sourceClasspathEntry);
>> IClasspathEntry jreClasspathEntry =
>> JavaCore.newVariableEntry
>> (new Path(JavaRuntime.JRELIB_VARIABLE), new
>> Path(JavaRuntime.JRESRC_VARIABLE), new
>> Path(JavaRuntime.JRESRCROOT_VARIABLE));
>> for (Iterator<IClasspathEntry> i =
>> classpathEntries.iterator(); i.hasNext(); )
>> {
>> IClasspathEntry classpathEntry = i.next();
>> if
>> (classpathEntry.getPath().isPrefixOf(jreClasspathEntry.getPa th()))
>> {
>> i.remove();
>> }
>> }
>> String jreContainer = JavaRuntime.JRE_CONTAINER;
>> String complianceLevel =
>> CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project);
>> if ("1.5".equals(complianceLevel))
>> {
>> jreContainer +=
>>
>> " /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J 2SE-1.5 ";
>> }
>> else if ("1.6".equals(complianceLevel))
>> {
>> jreContainer +=
>>
>> " /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J avaSE-1.6 ";
>> }
>> classpathEntries.add(JavaCore.newContainerEntry(new
>> Path(jreContainer)));
>> }
>> if ((style & EMF_EMPTY_PROJECT_STYLE) == 0)
>> {
>> if ((style & EMF_PLUGIN_PROJECT_STYLE) != 0)
>> {
>> classpathEntries.add(JavaCore.newContainerEntry(new
>> Path("org.eclipse.pde.core.requiredPlugins")));
>> // Remove variables since the plugin.xml should
>> provide the complete path information.
>> //
>> for (Iterator<IClasspathEntry> i =
>> classpathEntries.iterator(); i.hasNext(); )
>> {
>> IClasspathEntry classpathEntry = i.next();
>> if (classpathEntry.getEntryKind() ==
>> IClasspathEntry.CPE_VARIABLE &&
>>
>> !JavaRuntime.JRELIB_VARIABLE.equals(classpathEntry.getPath() .toString())
>> ||
>> classpathEntry.getEntryKind() ==
>> IClasspathEntry.CPE_PROJECT)
>> {
>> i.remove();
>> }
>> }
>> }
>> else
>> {
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_CORE_RUNTIME", "org.eclipse.core.runtime");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_CORE_RESOURCES", "org.eclipse.core.resources");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "EMF_COMMON", "org.eclipse.emf.common");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "EMF_ECORE", "org.eclipse.emf.ecore");
>> if ((style & EMF_XML_PROJECT_STYLE) != 0)
>> {
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
>> }
>> if ((style & EMF_MODEL_PROJECT_STYLE) == 0)
>> {
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "EMF_EDIT", "org.eclipse.emf.edit");
>> if ((style & EMF_EDIT_PROJECT_STYLE) == 0)
>> {
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_SWT", "org.eclipse.swt");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_JFACE", "org.eclipse.jface");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_UI_VIEWS", "org.eclipse.ui.views");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_UI_EDITORS", "org.eclipse.ui.editors");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_UI_IDE", "org.eclipse.ui.ide");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "ECLIPSE_UI_WORKBENCH", "org.eclipse.ui.workbench");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "EMF_COMMON_UI", "org.eclipse.emf.common.ui");
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "EMF_EDIT_UI", "org.eclipse.emf.edit.ui");
>> if ((style & EMF_XML_PROJECT_STYLE) == 0)
>> {
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
>> }
>> }
>> }
>> if ((style & EMF_TESTS_PROJECT_STYLE) != 0)
>> {
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>> "JUNIT", "org.junit");
>> }
>> if (pluginVariables != null)
>> {
>> for (Iterator<?> i = pluginVariables.iterator();
>> i.hasNext(); )
>> {
>> Object variable = i.next();
>> if (variable instanceof IClasspathEntry)
>> {
>> classpathEntries.add((IClasspathEntry)variable);
>> }
>> else if (variable instanceof String)
>> {
>> String pluginVariable = (String)variable;
>> String name;
>> String id;
>> int index = pluginVariable.indexOf("=");
>> if (index == -1)
>> {
>> name =
>> pluginVariable.replace('.','_').toUpperCase();
>> id = pluginVariable;
>> }
>> else
>> {
>> name = pluginVariable.substring(0, index);
>> id = pluginVariable.substring(index + 1);
>> }
>>
>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries , name, id);
>> }
>> }
>> }
>> }
>> }
>> javaProject.setRawClasspath
>> (classpathEntries.toArray(new
>> IClasspathEntry[classpathEntries.size()]),
>> new SubProgressMonitor(progressMonitor, 1));
>> }
>> if (isInitiallyEmpty)
>> {
>> javaProject.setOutputLocation(new Path("/" +
>> javaSource.segment(0) + "/bin"), new
>> SubProgressMonitor(progressMonitor, 1));
>> }
>> }
>> catch (Exception exception)
>> {
>> exception.printStackTrace();
>> CodeGenEcorePlugin.INSTANCE.log(exception);
>> }
>> finally
>> {
>> progressMonitor.done();
>> }
>> return project;
>> }
>>
>>
>>
>>
>> hannes wrote:
>>> I am writing a plugin generator. the generated plugin is an editor.
>>> the Idea is, you walk trough a wizard, and afterwards, you have a
>>> generated plugin.
>>> The code is generated, but now I have following problem,
>>>
>>> "The project was not built since its build path is incomplete.
>>> Cannot find the class file for java.lang.Object. Fix the build path
>>> then try building this project"
>>>
>>> what should I do, in which file can I specify the build-path?
>>>
>>>
>>> thanx in advance.
>>>
>>> Hannes
>>
Re: eclipse plugin generator problem [message #246217 is a reply to message #246135] Wed, 25 July 2007 18:43 Go to previous message
Eclipse UserFriend
Originally posted by: hannes.de-bondt.org

In fact, I was looking for using EMF, it looks very nice... but those
damn deadlines...

I'll take a look for the .classpath tomorrow.
Thanx

Hannes

Ed Merks wrote:
> Hannes,
>
> I wasn't trying to suggest you should use EMF, but rather providing a
> working example. If you installed EMF you could set breakpoints and
> watch the behavior. The most important part of the example below for
> you sounds like the setting of the JRE into the classapth and finally
> calling setRawClasspath on the Java project. So look closely at the
> .classpath file in your result verses a working project and keep in mind
> that you just set a good classpath with the right entries to produce
> your desired result.
>
>
> hannes wrote:
>> I tried to understand the code, but is was very dificult.
>>
>> I allready had a dirty solution, without the EMF. The deadline for
>> this project is way to short to chance to EMF now. so I will have to
>> do it quick and dirty.
>>
>> But the problem with the wrong build path still exists.
>> Is there someone who can tell me where (so in which file) I can adapt
>> the build path.
>>
>> Thanx in advance
>>
>> Hannes
>>
>>
>> Ed Merks wrote:
>>> Hannes,
>>>
>>> Hopefully the JDT guys won't look at this and say, gross! ;-)
>>> Here's an example of how we create a plugin project in EMF (and
>>> you're probably missing the JRE setup):
>>>
>>> public static IProject createEMFProject
>>> (IPath javaSource,
>>> URI projectLocationURI,
>>> List<IProject> referencedProjects,
>>> Monitor monitor,
>>> int style,
>>> List<?> pluginVariables)
>>> {
>>> IProgressMonitor progressMonitor =
>>> BasicMonitor.toIProgressMonitor(monitor);
>>> String projectName = javaSource.segment(0);
>>> IProject project = null;
>>> try
>>> {
>>> List<IClasspathEntry> classpathEntries = new
>>> UniqueEList<IClasspathEntry>();
>>> progressMonitor.beginTask("", 10);
>>> progressMonitor.subTask
>>> (CodeGenEcorePlugin.INSTANCE.getString
>>> ("_UI_CreatingEMFProject_message",
>>> new Object [] { projectName, projectLocationURI !=
>>> null ? projectLocationURI.toString() : projectName }));
>>> IWorkspace workspace = ResourcesPlugin.getWorkspace();
>>> project = workspace.getRoot().getProject(projectName);
>>> // Clean up any old project information.
>>> //
>>> if (!project.exists())
>>> {
>>> URI location = projectLocationURI;
>>> if (location == null)
>>> {
>>> location =
>>>
>>> URI.createFileURI(workspace.getRoot().getLocation().append(p rojectName).toOSString());
>>>
>>> }
>>> location = location.appendSegment(".project");
>>> File projectFile = new File(location.toString());
>>> if (projectFile.exists())
>>> {
>>> projectFile.renameTo(new File(location.toString() +
>>> ".old"));
>>> }
>>> }
>>> IJavaProject javaProject = JavaCore.create(project);
>>> IProjectDescription projectDescription = null;
>>> if (!project.exists())
>>> {
>>> projectDescription =
>>> ResourcesPlugin.getWorkspace().newProjectDescription(project Name);
>>> if (projectLocationURI != null)
>>> {
>>> projectDescription.setLocationURI(new
>>> java.net.URI(projectLocationURI.toString()));
>>> }
>>> project.create(projectDescription, new
>>> SubProgressMonitor(progressMonitor, 1));
>>> }
>>> else
>>> {
>>> projectDescription = project.getDescription();
>>>
>>> classpathEntries.addAll(Arrays.asList(javaProject.getRawClas spath()));
>>> }
>>> boolean isInitiallyEmpty = classpathEntries.isEmpty();
>>> {
>>> if (referencedProjects.size() != 0 && (style &
>>> (EMF_PLUGIN_PROJECT_STYLE | EMF_EMPTY_PROJECT_STYLE)) == 0)
>>> {
>>> projectDescription.setReferencedProjects
>>> (referencedProjects.toArray(new
>>> IProject[referencedProjects.size()]));
>>> for (IProject referencedProject : referencedProjects)
>>> {
>>> IClasspathEntry referencedProjectClasspathEntry =
>>> JavaCore.newProjectEntry(referencedProject.getFullPath());
>>> classpathEntries.add(referencedProjectClasspathEntry);
>>> }
>>> }
>>> String [] natureIds =
>>> projectDescription.getNatureIds();
>>> if (natureIds == null)
>>> {
>>> natureIds = new String [] { JavaCore.NATURE_ID };
>>> }
>>> else
>>> {
>>> boolean hasJavaNature = false;
>>> boolean hasPDENature = false;
>>> for (int i = 0; i < natureIds.length; ++i)
>>> {
>>> if (JavaCore.NATURE_ID.equals(natureIds[i]))
>>> {
>>> hasJavaNature = true;
>>> }
>>> if
>>> ("org.eclipse.pde.PluginNature".equals(natureIds[i]))
>>> {
>>> hasPDENature = true;
>>> }
>>> }
>>> if (!hasJavaNature)
>>> {
>>> String [] oldNatureIds = natureIds;
>>> natureIds = new String [oldNatureIds.length + 1];
>>> System.arraycopy(oldNatureIds, 0, natureIds, 0,
>>> oldNatureIds.length);
>>> natureIds[oldNatureIds.length] = JavaCore.NATURE_ID;
>>> }
>>> if (!hasPDENature)
>>> {
>>> String [] oldNatureIds = natureIds;
>>> natureIds = new String [oldNatureIds.length + 1];
>>> System.arraycopy(oldNatureIds, 0, natureIds, 0,
>>> oldNatureIds.length);
>>> natureIds[oldNatureIds.length] =
>>> "org.eclipse.pde.PluginNature";
>>> }
>>> }
>>> projectDescription.setNatureIds(natureIds);
>>> ICommand [] builders =
>>> projectDescription.getBuildSpec();
>>> if (builders == null)
>>> {
>>> builders = new ICommand [0];
>>> }
>>> boolean hasManifestBuilder = false;
>>> boolean hasSchemaBuilder = false;
>>> for (int i = 0; i < builders.length; ++i)
>>> {
>>> if
>>>
>>> ("org.eclipse.pde.ManifestBuilder".equals(builders[i].getBuilderName()))
>>> {
>>> hasManifestBuilder = true;
>>> }
>>> if
>>>
>>> ("org.eclipse.pde.SchemaBuilder".equals(builders[i].getBuilderName()))
>>> {
>>> hasSchemaBuilder = true;
>>> }
>>> }
>>> if (!hasManifestBuilder)
>>> {
>>> ICommand [] oldBuilders = builders;
>>> builders = new ICommand [oldBuilders.length + 1];
>>> System.arraycopy(oldBuilders, 0, builders, 0,
>>> oldBuilders.length);
>>> builders[oldBuilders.length] =
>>> projectDescription.newCommand();
>>>
>>> builders[oldBuilders.length].setBuilderName("org.eclipse.pde.ManifestBuilder ");
>>>
>>> }
>>> if (!hasSchemaBuilder)
>>> {
>>> ICommand [] oldBuilders = builders;
>>> builders = new ICommand [oldBuilders.length + 1];
>>> System.arraycopy(oldBuilders, 0, builders, 0,
>>> oldBuilders.length);
>>> builders[oldBuilders.length] =
>>> projectDescription.newCommand();
>>>
>>> builders[oldBuilders.length].setBuilderName("org.eclipse.pde.SchemaBuilder ");
>>>
>>> }
>>> projectDescription.setBuildSpec(builders);
>>> project.open(new
>>> SubProgressMonitor(progressMonitor, 1));
>>> project.setDescription(projectDescription, new
>>> SubProgressMonitor(progressMonitor, 1));
>>> IContainer sourceContainer = project;
>>> if (javaSource.segmentCount() > 1)
>>> {
>>> sourceContainer =
>>> project.getFolder(javaSource.removeFirstSegments(1).makeAbso lute());
>>> if (!sourceContainer.exists())
>>> {
>>> ((IFolder)sourceContainer).create(false, true, new
>>> SubProgressMonitor(progressMonitor, 1));
>>> }
>>> }
>>> if (isInitiallyEmpty)
>>> {
>>> IClasspathEntry sourceClasspathEntry =
>>> JavaCore.newSourceEntry(javaSource);
>>> for (Iterator<IClasspathEntry> i =
>>> classpathEntries.iterator(); i.hasNext(); )
>>> {
>>> IClasspathEntry classpathEntry = i.next();
>>> if (classpathEntry.getPath().isPrefixOf(javaSource))
>>> {
>>> i.remove();
>>> }
>>> }
>>> classpathEntries.add(0, sourceClasspathEntry);
>>> IClasspathEntry jreClasspathEntry =
>>> JavaCore.newVariableEntry
>>> (new Path(JavaRuntime.JRELIB_VARIABLE), new
>>> Path(JavaRuntime.JRESRC_VARIABLE), new
>>> Path(JavaRuntime.JRESRCROOT_VARIABLE));
>>> for (Iterator<IClasspathEntry> i =
>>> classpathEntries.iterator(); i.hasNext(); )
>>> {
>>> IClasspathEntry classpathEntry = i.next();
>>> if
>>> (classpathEntry.getPath().isPrefixOf(jreClasspathEntry.getPa th()))
>>> {
>>> i.remove();
>>> }
>>> }
>>> String jreContainer = JavaRuntime.JRE_CONTAINER;
>>> String complianceLevel =
>>> CodeGenUtil.EclipseUtil.getJavaComplianceLevel(project);
>>> if ("1.5".equals(complianceLevel))
>>> {
>>> jreContainer +=
>>>
>>> " /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J 2SE-1.5 ";
>>> }
>>> else if ("1.6".equals(complianceLevel))
>>> {
>>> jreContainer +=
>>>
>>> " /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J avaSE-1.6 ";
>>> }
>>> classpathEntries.add(JavaCore.newContainerEntry(new
>>> Path(jreContainer)));
>>> }
>>> if ((style & EMF_EMPTY_PROJECT_STYLE) == 0)
>>> {
>>> if ((style & EMF_PLUGIN_PROJECT_STYLE) != 0)
>>> {
>>> classpathEntries.add(JavaCore.newContainerEntry(new
>>> Path("org.eclipse.pde.core.requiredPlugins")));
>>> // Remove variables since the plugin.xml should
>>> provide the complete path information.
>>> //
>>> for (Iterator<IClasspathEntry> i =
>>> classpathEntries.iterator(); i.hasNext(); )
>>> {
>>> IClasspathEntry classpathEntry = i.next();
>>> if (classpathEntry.getEntryKind() ==
>>> IClasspathEntry.CPE_VARIABLE &&
>>>
>>> !JavaRuntime.JRELIB_VARIABLE.equals(classpathEntry.getPath() .toString())
>>> ||
>>> classpathEntry.getEntryKind() ==
>>> IClasspathEntry.CPE_PROJECT)
>>> {
>>> i.remove();
>>> }
>>> }
>>> }
>>> else
>>> {
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_CORE_RUNTIME", "org.eclipse.core.runtime");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_CORE_RESOURCES", "org.eclipse.core.resources");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "EMF_COMMON", "org.eclipse.emf.common");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "EMF_ECORE", "org.eclipse.emf.ecore");
>>> if ((style & EMF_XML_PROJECT_STYLE) != 0)
>>> {
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
>>> }
>>> if ((style & EMF_MODEL_PROJECT_STYLE) == 0)
>>> {
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "EMF_EDIT", "org.eclipse.emf.edit");
>>> if ((style & EMF_EDIT_PROJECT_STYLE) == 0)
>>> {
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_SWT", "org.eclipse.swt");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_JFACE", "org.eclipse.jface");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_UI_VIEWS", "org.eclipse.ui.views");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_UI_EDITORS", "org.eclipse.ui.editors");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_UI_IDE", "org.eclipse.ui.ide");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "ECLIPSE_UI_WORKBENCH", "org.eclipse.ui.workbench");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "EMF_COMMON_UI", "org.eclipse.emf.common.ui");
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "EMF_EDIT_UI", "org.eclipse.emf.edit.ui");
>>> if ((style & EMF_XML_PROJECT_STYLE) == 0)
>>> {
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "EMF_ECORE_XMI", "org.eclipse.emf.ecore.xmi");
>>> }
>>> }
>>> }
>>> if ((style & EMF_TESTS_PROJECT_STYLE) != 0)
>>> {
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries ,
>>> "JUNIT", "org.junit");
>>> }
>>> if (pluginVariables != null)
>>> {
>>> for (Iterator<?> i = pluginVariables.iterator();
>>> i.hasNext(); )
>>> {
>>> Object variable = i.next();
>>> if (variable instanceof IClasspathEntry)
>>> {
>>> classpathEntries.add((IClasspathEntry)variable);
>>> }
>>> else if (variable instanceof String)
>>> {
>>> String pluginVariable = (String)variable;
>>> String name;
>>> String id;
>>> int index = pluginVariable.indexOf("=");
>>> if (index == -1)
>>> {
>>> name =
>>> pluginVariable.replace('.','_').toUpperCase();
>>> id = pluginVariable;
>>> }
>>> else
>>> {
>>> name = pluginVariable.substring(0, index);
>>> id = pluginVariable.substring(index + 1);
>>> }
>>>
>>> CodeGenUtil.EclipseUtil.addClasspathEntries(classpathEntries , name, id);
>>> }
>>> }
>>> }
>>> }
>>> }
>>> javaProject.setRawClasspath
>>> (classpathEntries.toArray(new
>>> IClasspathEntry[classpathEntries.size()]),
>>> new SubProgressMonitor(progressMonitor, 1));
>>> }
>>> if (isInitiallyEmpty)
>>> {
>>> javaProject.setOutputLocation(new Path("/" +
>>> javaSource.segment(0) + "/bin"), new
>>> SubProgressMonitor(progressMonitor, 1));
>>> }
>>> }
>>> catch (Exception exception)
>>> {
>>> exception.printStackTrace();
>>> CodeGenEcorePlugin.INSTANCE.log(exception);
>>> }
>>> finally
>>> {
>>> progressMonitor.done();
>>> }
>>> return project;
>>> }
>>>
>>>
>>>
>>>
>>> hannes wrote:
>>>> I am writing a plugin generator. the generated plugin is an editor.
>>>> the Idea is, you walk trough a wizard, and afterwards, you have a
>>>> generated plugin.
>>>> The code is generated, but now I have following problem,
>>>>
>>>> "The project was not built since its build path is incomplete.
>>>> Cannot find the class file for java.lang.Object. Fix the build path
>>>> then try building this project"
>>>>
>>>> what should I do, in which file can I specify the build-path?
>>>>
>>>>
>>>> thanx in advance.
>>>>
>>>> Hannes
>>>
Previous Topic:ASTParser Help
Next Topic:Request about Importing Java Compiler
Goto Forum:
  


Current Time: Wed May 28 23:30:20 EDT 2025

Powered by FUDForum. Page generated in 0.04742 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top