|
1 | 1 | --- |
2 | 2 | parent: Plugins |
3 | | -layout: bnd |
4 | | ---- |
5 | | ---- |
6 | | -title: Eclipse Plugin |
7 | 3 | layout: default |
| 4 | +title: Eclipse Plugin |
8 | 5 | summary: Will add .project and .classpath files to newly created projects |
9 | | ---- |
| 6 | +--- |
| 7 | + |
| 8 | +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. |
| 9 | + |
| 10 | +## How It Works |
| 11 | + |
| 12 | +When a new project is created, the Eclipse plugin will: |
| 13 | + |
| 14 | +1. Create a `.project` file (Eclipse project descriptor) |
| 15 | +2. Create a `.classpath` file (Eclipse classpath configuration) |
| 16 | + |
| 17 | +If either file already exists, the plugin will not overwrite it. |
| 18 | + |
| 19 | +## Custom Templates |
| 20 | + |
| 21 | +The plugin looks for custom templates in the workspace configuration: |
| 22 | + |
| 23 | +- Custom `.project` template: `cnf/eclipse/project.tmpl` |
| 24 | +- Custom `.classpath` template: `cnf/eclipse/classpath.tmpl` |
| 25 | + |
| 26 | +If custom templates exist, they will be used. Otherwise, default templates are used. |
| 27 | + |
| 28 | +## Template Processing |
| 29 | + |
| 30 | +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. |
| 31 | + |
| 32 | +For example, in your template, you can use: |
| 33 | +- `${project.name}` - the project name |
| 34 | +- `${basedir}` - the base directory |
| 35 | +- Any other project properties defined in the project's `bnd.bnd` file |
| 36 | + |
| 37 | +## Initialization |
| 38 | + |
| 39 | +The Eclipse plugin also runs during workspace initialization, ensuring that: |
| 40 | +- The workspace `cnf` project has the required `.project` and `.classpath` files |
| 41 | +- All existing projects in the workspace get updated Eclipse files if they're missing |
| 42 | + |
| 43 | +## Usage in build.bnd |
| 44 | + |
| 45 | +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`: |
| 46 | + |
| 47 | +```properties |
| 48 | +-plugin.Eclipse: \ |
| 49 | + aQute.bnd.plugin.eclipse.EclipsePlugin |
| 50 | +``` |
| 51 | + |
| 52 | +## Example Workspace Setup |
| 53 | + |
| 54 | +To create custom Eclipse templates: |
| 55 | + |
| 56 | +1. Create a custom `.project` template at `cnf/eclipse/project.tmpl`: |
| 57 | + |
| 58 | +```xml |
| 59 | +<?xml version="1.0" encoding="UTF-8"?> |
| 60 | +<projectDescription> |
| 61 | + <name>${project.name}</name> |
| 62 | + <comment>Custom Eclipse project for ${project.name}</comment> |
| 63 | + <projects> |
| 64 | + </projects> |
| 65 | + <buildSpec> |
| 66 | + <buildCommand> |
| 67 | + <name>org.eclipse.jdt.core.javabuilder</name> |
| 68 | + <arguments> |
| 69 | + </arguments> |
| 70 | + </buildCommand> |
| 71 | + </buildSpec> |
| 72 | + <natures> |
| 73 | + <nature>org.eclipse.jdt.core.javanature</nature> |
| 74 | + </natures> |
| 75 | +</projectDescription> |
| 76 | +``` |
| 77 | + |
| 78 | +2. Create a custom `.classpath` template at `cnf/eclipse/classpath.tmpl`: |
| 79 | + |
| 80 | +```xml |
| 81 | +<?xml version="1.0" encoding="UTF-8"?> |
| 82 | +<classpath> |
| 83 | + <classpathentry kind="src" path="src"/> |
| 84 | + <classpathentry kind="output" path="bin"/> |
| 85 | + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
| 86 | +</classpath> |
| 87 | +``` |
| 88 | + |
| 89 | +These templates will be used for all new projects created in the workspace. |
| 90 | + |
| 91 | +<hr /> |
| 92 | +TODO Needs review - AI Generated content |
0 commit comments