|
| 1 | +--- |
| 2 | +author: "Phong Nguyen" |
| 3 | +title: "Eclipse Project" |
| 4 | +date: "2025-2-5" |
| 5 | +description: "Eclipse Project." |
| 6 | +tags: ["eclipse"] #tags search |
| 7 | +FAcategories: ["syntax"] #The category of the post, similar to tags but usually for broader classification. |
| 8 | +FAseries: ["Themes Guide"] #indicates that this post is part of a series of related posts |
| 9 | +aliases: ["migrate-from-jekyl"] #Alternative URLs or paths that can be used to access this post, useful for redirects from old posts or similar content. |
| 10 | +ShowToc: true # Determines whether to display the Table of Contents (TOC) for the post. |
| 11 | +TocOpen: true # Controls whether the TOC is expanded when the post is loaded. |
| 12 | +weight: 8 # The order in which the post appears in a list of posts. Lower numbers make the post appear earlier. |
| 13 | +--- |
| 14 | +Explain how to create the eclipse project. |
| 15 | +**References:** |
| 16 | +[Wizards and Dialogs](https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Fproject_wizards%2Fnew_fragment_project.htm) |
| 17 | +[Eclipse fragment projects - Tutorial](https://www.vogella.com/tutorials/EclipseFragmentProject/article.html#example-manifest-for-a-fragment)<br> |
| 18 | +## 1. New Project Creation Wizards |
| 19 | +- Every `plugin, fragment, feature` and update site is represented by a single project in the workspace and allow PDE(Plugin Development Environment) to validate their manifest file(s). |
| 20 | +- `File > New > Project... > Plug-in Development` |
| 21 | + |
| 22 | +- Use a Plugin Project if we're building new functionality. |
| 23 | +- Use a Fragment Project if we need to modify an existing plugin without changing its core code. |
| 24 | +## 1.1. Plugin project |
| 25 | +- **A plugin project** (or "bundle") is the fundamental building block in an Eclipse-based application. |
| 26 | + |
| 27 | +- **Use-cases:** |
| 28 | + - We are developing a primary feature of an application. |
| 29 | + - We need to define new APIs, extension points, or contribute UI components. |
| 30 | + |
| 31 | +- **Manifest for a plugin project (OSGi bundle)** |
| 32 | +```xml |
| 33 | +Manifest-Version: 1.0 |
| 34 | +Bundle-ManifestVersion: 2 |
| 35 | +Bundle-Name: Plugin Name |
| 36 | +Bundle-SymbolicName: test.plugin.project;singleton:=true # unique identifier for an plugin, The singleton:=true means only one instance of this plugin can be active in the runtime environment. |
| 37 | +Bundle-Version: 1.0.0.qualifier # is mandatory and must be of the form major.minor.micro.qualifier |
| 38 | +Bundle-Activator: test.plugin.Activator # used to control the bundle's life cycle |
| 39 | +Bundle-Vendor: Vendor Name |
| 40 | +Require-Bundle: org.eclipse.swt, # lists dependencies on other plugins, this means the current plugin depends on org.eclipse.swt, ... and can use all exported packages from it. |
| 41 | + org.eclipse.jface;bundle-version="[3.205.0,4.0.0)", |
| 42 | + org.eclipse.jdt.annotation;bundle-version="[2.2.0,3.0.0)";resolution:=optional # optional, if the bundle is missing, the plugin must still work without failing. |
| 43 | +Import-Package: com.example.utils # this means the plugin only depends on specific packages, not the whole bundle. |
| 44 | +Automatic-Module-Name: test.plugin.project |
| 45 | +Bundle-ActivationPolicy: lazy # Means the plugin will not be activated until needed |
| 46 | +Export-Package: com.example.utils # Other plugins can use the classes in com.example.utils |
| 47 | +Bundle-RequiredExecutionEnvironment: JavaSE-21 # the Java version required to run the plugin. |
| 48 | +``` |
| 49 | + |
| 50 | +- **Versioning Rule** (Semantic Versioning - SemVer) |
| 51 | +MAJOR version (X.0.0): Incompatible API changes (breaking changes). |
| 52 | +MINOR version (X.Y.0): Backward-compatible feature additions. |
| 53 | +PATCH version (X.Y.Z): Backward-compatible bug fixes. |
| 54 | +<br> |
| 55 | + |
| 56 | + |
| 57 | +## 1.2. Fragment project |
| 58 | +- **A fragment** is an optional attachment to another plug-in. This other plug-in is called the host plug-in. At runtime the fragment is merged with its host plug-in. |
| 59 | + |
| 60 | +- **Use-cases:** |
| 61 | + - Contain test classes: This way, tests can access the internal API of the plugin classes and test it. (Tests can be contained in own their `plugin project`, but they can only test the external API of the other plugin) |
| 62 | + - Contribute property files for additional translations. |
| 63 | + - Provide native code which is specific to certain operating systems (OS) |
| 64 | + - Contain resources like icon sets or other images |
| 65 | + |
| 66 | +- **Manifest for a fragment project** |
| 67 | + |
| 68 | +```xml |
| 69 | +Manifest-Version: 1.0 |
| 70 | +Bundle-ManifestVersion: 2 |
| 71 | +Bundle-Name: %fragmentName |
| 72 | +Bundle-SymbolicName: org.eclipse.ui.win32 |
| 73 | +Bundle-Version: 3.4.300.qualifier # is mandatory and must be of the form major.minor.micro.qualifier |
| 74 | +Bundle-ClassPath: . |
| 75 | +Bundle-Vendor: %providerName |
| 76 | +Fragment-Host: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)" |
| 77 | +Bundle-Localization: fragment-win32 |
| 78 | +Export-Package: org.eclipse.ui.internal.editorsupport.win32;x-internal:=true |
| 79 | +Eclipse-PlatformFilter: (osgi.ws=win32) |
| 80 | +Bundle-RequiredExecutionEnvironment: JavaSE-21 |
| 81 | +Automatic-Module-Name: org.eclipse.ui.win32 |
| 82 | +``` |
| 83 | + |
| 84 | + |
0 commit comments