- Notifications
You must be signed in to change notification settings - Fork0
Eclipse plugin that provides integration of Java projects into a bndtools workspace, by providing these Java projects via a local bndtools repository.
License
DaHoC/Java2Bndtools
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- What is it and what does it do
- Prerequisites
- How to install?
- How to use?
- Example usage
- How does it work?
- To-do
It is an Eclipse plugin that provides integration of Java projects into a bndtools workspace, by making these Java projects available in a local bndtools repository.
- Eclipse workspace with bndtools workspace with the mandatory bnd cnf project folder and a bnd repository named "Local"
- A Java project (having the org.eclipse.jdt.core.javanature nature) being contained within the same Eclipse workspace
- The
META-INF/MANIFEST.MF
of the Java project must be present, readable and must have the following attributes (Bundle-Version
defaults to0.0.0
if not specified), mind the mandatory newline at the end of the file:
Manifest-Version: 1.0Bundle-Name: Dummy projectBundle-SymbolicName: com.foo.barBundle-ManifestVersion: 2Bundle-Version: 1.0.0
If your bnd workspace is missing theLocal
repository, you can add the entry to the maincnf/build.bnd
file:
-plugin.7.Local: \ aQute.bnd.deployer.repository.LocalIndexedRepo; \ name = Local; \ pretty = true; \ local = ${build}/local
The Eclipse update site is generated by the enclosed de.janhendriks.java2bnd.updatesite project (which uses the enclosed de.janhendriks.java2bnd.feature project which in turn uses this de.janhendriks.java2bnd project) and can be found at following URL:
https://github.com/DaHoC/Java2Bndtools/raw/master/de.janhendriks.java2bnd.updatesite/
Don't mind the potential HTTP 404 response as the index.html is missing, but Eclipseshould rely on the existingsite.xml
file
Clone this repo, and use the updatesite project as source folder as local Eclipse update site.
Make sure that the prerequisites are met.
To associate the plugin with a Java project, you need to add a nature (which adds the corresponding builder) to the project you want to provide to the local bndtools workspace.
Each time afull build on the Java project is triggered, e.g. by doing aProject → Clean… → Build (automatically), the updated project should appear as bundle in the "Local" bndtools workspace repository.
The name of the bundle corresponds to theBundle-SymbolicName
MANIFEST.MF
entry, the version toBundle-Version
.
This bundle can then be referenced by a bnd project.
To associate the plugin with a Java project, there are several approaches:
Select the Java projects which should be considered and included as bnd dependencies in the "Package Explorer" or "Project Explorer" view, right-click to open the context menu →Add Java2bnd nature
Select the Java project, go into its properties (e.g. by right-clicking the project →Properties), selectProject Natures →Add... →Add Java2bnd nature as depicted below:
After hittingApply and Close, the project nature is added, the corresponding builder is added and registered and the project is build and should immediately appear in the bnd workspace "Local" repository.
For the Java project add thede.janhendriks.java2bnd.nature
andbuildCommand
de.janhendriks.java2bnd.builder
as last build entry as shown in the following.project
entries / builder:
<?xml version="1.0" encoding="UTF-8"?><projectDescription>...<buildSpec><buildCommand><name>org.eclipse.jdt.core.javabuilder</name><arguments></arguments></buildCommand><buildCommand><name>de.janhendriks.java2bnd.builder</name><arguments></arguments></buildCommand></buildSpec><natures><nature>org.eclipse.jdt.core.javanature</nature><nature>de.janhendriks.java2bnd.nature</nature></natures></projectDescription>
Consider aJava project in your bndtools workspace that has aBundle-SymbolicName
ofcom.foo.java
and aBundle-Version
of2.1.0
defined in itsMETA-INF/MANIFEST.MF
.
Besides this project, thecom.bar.bnd
bndtools project is present in the same Eclipse workspace, which is to be configured to require thecom.foo.java
bundle as dependency.
First a full build of the Java projectcom.foo.java
is to be done (e.g. byProject → Clean… → Build (automatically)).Afterwards, the corresponding bundle should now be present in the "Local" bndtools workspace repository (seeBndtools perspective → Repositories → Local).
com.foo.java
can now be referenced from thecom.bar.bnd/bnd.bnd
file, e.g.
-buildpath = com.foo.java;version=2.1.0
Thecom.bar.bnd
bndtools project now references thecom.foo.java
bundle as dependency and the exposed API (including JavaDoc) and further bndtools/OSGi instructions can be used (likeRequire-Capability
,Import-Package
,-runbundles
and so on).
After each successful full build of thecom.foo.java
project, the corresponding bundle in the "Local" bndtools repository is updated.
If the Java project is given the additional nature (and builder) as mentioned before, the builder registers itself as the last builder to execute in the chain, to make sure it's called after all other builders doing e.g. source generation or resource handling, especially after the Java builder.
During eachfull build of this Java project, the Java2bndtools builder packs generated Java artifacts of the project into a temporary jar file using the Eclipse-internal jar package exporter with custom settings.
This temporary JAR file is passed via stream to the bnd workspace "Local" repository where it should appear.It is automatically overwritten for each new full build and the bnd workspace repository is refreshed automatically.
- Support incremental builds to some extent (if possible and feasible at all)
- Provide minimal sample workspace (from the example)
- If MANIFEST.MF is missing, use a best-effort-approach, e.g. by setting
Manifest-Version: 1.0Bundle-Name: <Eclipse project name>Bundle-SymbolicName: <Eclipse project name>Bundle-ManifestVersion: 2Bundle-Version: 0.0.0