patrickfav/bcrypt

[feature request] Support packaging as an OSGi bundle

Andrew-Cottrell opened this issue · 10 comments

I suspect the following would need to be changed/added in the POM

<project>
	<packaging>bundle</packaging>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>4.1.0</version>
				<extensions>true</extensions>
			</plugin>
		</plugins>
	</build>
</project>

Hi,

As I do not use OSGi I'm not fully comfortable maintaining it. How does this work? Does it create a new OSGi compatible jar? Is it the same jar? Is there no easy way to wrap jars to make them OSGi compatible (outside of this project)?

Hi patrickfav

Yes, it creates an OSGi compatible jar and it's the same jar. The jar should be exactly the same as before, other than additions to META-INF/MANIFEST.MF. It is easy to wrap jars; however, this makes them much harder to use: can't simply add the dependency to a project's pom.xml.

FYI, another BCrypt implementation does this
svenkubiak/jBCrypt@89da34b
https://github.com/svenkubiak/jBCrypt/blob/0.4.1/pom.xml
https://mvnrepository.com/artifact/de.svenkubiak/jBCrypt/0.4.1

Alright, let me look into this, if the change is transparent for anybody that does not use OSGi then thats fine for me.

Yes, the change should be transparent for non-OSGi uses. Thanks for looking in to this.

Hi,

I've pushed the changes to this feature branch: https://github.com/patrickfav/bcrypt/tree/feat-15-osgi

Could you please checkout, in the root directory run

./mvnw clean install

to install the snapshot version into your local repo and change your dependency to

    <dependency>
        <groupId>at.favre.lib</groupId>
        <artifactId>bcrypt</artifactId>
        <version>0.8.0-SNAPSHOT</version>
    </dependency>

and give me feedback if that works? I have no osgi project to test it on (and to be frank never used it before) :)

Cheers!

Hi

Looks like at.favre.lib:bcrypt is perfect. I was able to build and install the bcrypt-feat-15-osgi modules using Maven, and then to deploy and depend upon the bcrypt module as an OSGi bundle.

Import-Package: at.favre.lib.crypto.bcrypt;version="[0.8.0,0.9.0)"

But it's only partly working as there is a dependency on at.favre.lib:bytes, which is not currently OSGi compatible. Without at.favre.lib:bytes also being an OSGi bundle it doesn't work at runtime.

Cheers!

(sorry, didn't mean to close)

Hi, I've released a new bytes version with also OSGi support. For now the support is added, but I can't guarantee it for the lifetime of this project as the requirement that every transitive dependency must ALSO be OSGi compatible makes it quite restricting.

I'm soon releasing 0.8.0 - please leave me a line to tell me if the lib now works with your project.

Released.

BCrypt 0.8.0 (and Bytes 1.1.0) works great with my projects. Thanks for adding OSGi support.