This plugin automatically creates Eclipse project configuration files when a new project is created in the workspace. These files are essential for importing bnd projects into the Eclipse IDE.
How It Works
When a new project is created, the Eclipse plugin will:
- Create a
.projectfile (Eclipse project descriptor) - Create a
.classpathfile (Eclipse classpath configuration)
If either file already exists, the plugin will not overwrite it.
Custom Templates
The plugin looks for custom templates in the workspace configuration:
- Custom
.projecttemplate:cnf/eclipse/project.tmpl - Custom
.classpathtemplate:cnf/eclipse/classpath.tmpl
If custom templates exist, they will be used. Otherwise, default templates are used.
Template Processing
Before writing the template files to disk, they are processed by the project’s variable replacer. This allows you to use project variables within your custom templates.
For example, in your template, you can use:
${project.name}- the project name${basedir}- the base directory- Any other project properties defined in the project’s
bnd.bndfile
Initialization
The Eclipse plugin also runs during workspace initialization, ensuring that:
- The workspace
cnfproject has the required.projectand.classpathfiles - All existing projects in the workspace get updated Eclipse files if they’re missing
Usage in build.bnd
The Eclipse plugin is typically enabled automatically in bnd workspaces. If you need to explicitly enable it, add the following to your cnf/build.bnd:
-plugin.Eclipse: \
aQute.bnd.plugin.eclipse.EclipsePlugin
Example Workspace Setup
To create custom Eclipse templates:
- Create a custom
.projecttemplate atcnf/eclipse/project.tmpl:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>${project.name}</name>
<comment>Custom Eclipse project for ${project.name}</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
- Create a custom
.classpathtemplate atcnf/eclipse/classpath.tmpl:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
These templates will be used for all new projects created in the workspace.
TODO Needs review - AI Generated content