NeuronRobotics / nrjavaserial

A Java Serial Port system. This is a fork of the RXTX project that uses in jar loading of the native code.
Other
345 stars 143 forks source link

Modified build.xml for building OSGI bundle. #31

Closed cbareau-Orange closed 8 years ago

cbareau-Orange commented 9 years ago

Following issue #29, this is a modified version of the Ant build file so that it produces a bundle that it is “OSGi consistent”, with a valid OSGi manifest. The modification consists in adding “by hand” the missing manifest properties.

The bundle is produced by a new target “osgi-dist” that generates a file target/osgi/nrjavaserial-3.9.3.jar, which only differs from the target/nrjavaserial-3.9.3.jar by the manifest. This target is added in the default target’s dependencies.

MrDOS commented 9 years ago

I'm a little leery of defaulting to a Java 1.7 target. On one hand, Oracle only supports Java 8 now; on the other, a 1.7 target means the library won't be usable with the out-of-box Apple Java 6 JRE. Can we leave that at 1.6 for now, at least until we start using some 1.7 language features?

If the OSGi JAR differs from the “normal” JAR only by its manifest, does it actually need to be separate at all? If the OSGi manifest doesn't interfere with manually-classpath'd/Maven'd use of the archive and adds no more than a few KB of overhead, I'd say we might as well build a one-size-fits-all JAR and be done with it.

There are a number of alpha-version RXTX JARs floating around the web which have a 2.2-series version number. I'm not saying we should bump the OSGi package version number to the project version number (3.9.3), but can you speak to the possible implications of doing so?

Beyond the minor nitpicking, thank you very much for putting in the effort to add this. It's clearly a feature of interest to a number of users, and fixes a notable regression when comparing this project to RXTX.

cbareau-Orange commented 9 years ago

Well, there was no default compile.target and although I thought there was a need for it, I was not sure what was the best choice. Your point about the out-of-box Apple Java 6 JRE is a good argument for changing it to 1.6. As for the separate jar, there again I was hesitating about the implications in non OSGI environments, so I preferred to put it in a separate "pure OSGi" bundle, at least in a first step for discussion, but it may be preferable to directly integrate it in the "main" jar indeed.

MrDOS commented 8 years ago

@cbareau-Orange The project is now built only with Gradle (no more Ant or Maven) but I've opened a pull request (#42) to leverage the Gradle OSGi plugin. Here's an example of the sort of manifest it creates. Is this the sort of thing you were after?

Manifest-Version: 1.0
Export-Package: gnu.io;version="3.11.0",gnu.io.rfc2217;version="3.11.0
 ";uses:="gnu.io,org.apache.commons.net.telnet"
Bundle-SymbolicName: com.neuronrobotics.nrjavaserial
Bundle-Version: 3.11.0
Bundle-Name: nrjavaserial
Bundle-ManifestVersion: 2
Bnd-LastModified: 1447881535000
Import-Package: org.apache.commons.net.telnet;version="[3.3,4)"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))"
Created-By: 1.8.0_45 (Oracle Corporation)
Tool: Bnd-2.4.0.201411031534
MrDOS commented 8 years ago

Given that we're not using Ant any more at all, I'm going to close this pull request. Thank you, though, @cbareau-Orange, for taking a stab at this. I'd welcome your input on #42 (discussion seems to be occurring on #29) to make sure the end result meets your needs.