Skip to content

Commit e3aa42c

Browse files
authored
Use bnd-maven-plugin to fix osgi manifest headers (#28)
1 parent ef125a1 commit e3aa42c

File tree

3 files changed

+29
-40
lines changed

3 files changed

+29
-40
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ speed at which they compress/decompress/hash bytes.
167167

168168
Make sure you have a Java 7 installation in your [Maven toolchains.xml](https://maven.apache.org/guides/mini/guide-using-toolchains.html). You may also need a C compiler.
169169

170+
First run git submodule init and then git submodule update to initialize the lz4 submodule in src/lz4.
171+
170172
Then, run `./mvnw verify`.
171173

172174
Building a full artifact with native libraries for all supported platforms is more complex. We do this through github actions.

lz4-java.bnd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Bundle-SymbolicName: lz4-java
22
Bundle-Name: LZ4 Java Compression
3-
Bundle-Version:${ivy.revision}
4-
Export-Package: net.jpountz.*;version:=${packages.version}
5-
3+
Bundle-Version: ${version_cleanup;${ivy.version}}
4+
Export-Package: net.jpountz.*;version:=${version_cleanup;${packages.version}}
5+
-noee: true
6+
-removeheaders: Require-Capability

pom.xml

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
- Compile src/java, src/java-unsafe, and generated sources
99
- Include resources from src/resources
1010
- Include native libraries by extracting them from the published 1.8.0 jar
11-
- Wrap the jar with bnd 1.50.0 using lz4-java.bnd to match OSGi metadata
1211
- Preserve Automatic-Module-Name: org.lz4.java
13-
14-
Note: We deliberately do the bnd wrapping after the regular jar build and overwrite the main artifact,
15-
to keep the final jar identical in structure to the Ant "bundle" target output.
1612
-->
1713
<project xmlns="http://maven.apache.org/POM/4.0.0"
1814
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -72,6 +68,11 @@
7268
<native.cc>gcc</native.cc>
7369
<native.cflags></native.cflags>
7470
<native.ldflags></native.ldflags>
71+
72+
<!-- plugin versions -->
73+
<bnd.maven.plugin.version>7.1.0</bnd.maven.plugin.version>
74+
<packages.version>${project.version}</packages.version>
75+
<ivy.version>${project.version}</ivy.version>
7576
</properties>
7677

7778
<dependencies>
@@ -214,13 +215,30 @@
214215
<version>3.4.1</version>
215216
<configuration>
216217
<archive>
218+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
217219
<manifestEntries>
218220
<Automatic-Module-Name>org.lz4.java</Automatic-Module-Name>
219221
</manifestEntries>
220222
</archive>
221223
</configuration>
222224
</plugin>
223225

226+
<plugin>
227+
<groupId>biz.aQute.bnd</groupId>
228+
<artifactId>bnd-maven-plugin</artifactId>
229+
<version>${bnd.maven.plugin.version}</version>
230+
<executions>
231+
<execution>
232+
<goals>
233+
<goal>bnd-process</goal>
234+
</goals>
235+
</execution>
236+
</executions>
237+
<configuration>
238+
<bndfile>lz4-java.bnd</bndfile>
239+
</configuration>
240+
</plugin>
241+
224242
<plugin>
225243
<groupId>org.apache.maven.plugins</groupId>
226244
<artifactId>maven-antrun-plugin</artifactId>
@@ -229,7 +247,7 @@
229247
<dependency>
230248
<groupId>biz.aQute.bnd</groupId>
231249
<artifactId>biz.aQute.bnd.ant</artifactId>
232-
<version>7.1.0</version>
250+
<version>${bnd.maven.plugin.version}</version>
233251
</dependency>
234252
<dependency>
235253
<groupId>org.mvel</groupId>
@@ -257,38 +275,6 @@
257275
<goal>run</goal>
258276
</goals>
259277
</execution>
260-
<!-- Use bndwrap for OSGi stuff that I don't understand. Could probably use maven-bundle-plugin here... -->
261-
<execution>
262-
<id>bnd-wrap-jar</id>
263-
<phase>package</phase>
264-
<configuration>
265-
<target>
266-
<!-- Set properties used by lz4-java.bnd -->
267-
<property name="packages.version" value="${project.version}"/>
268-
<property name="ivy.revision" value="${project.version}"/>
269-
<property name="-noextraheaders" value="true"/>
270-
<property name="-reproducible" value="true"/>
271-
272-
<!-- Define bnd ant task from plugin dependency -->
273-
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="maven.plugin.classpath"/>
274-
275-
<!-- Wrap the plain jar into the final OSGi bundle -->
276-
<bndwrap definitions="${project.basedir}"
277-
output="${project.build.directory}/${project.build.finalName}-wrapped.jar"
278-
trace="true">
279-
<fileset dir="${project.build.directory}" includes="${project.build.finalName}.jar"/>
280-
</bndwrap>
281-
282-
<!-- Replace the original jar with the wrapped one (as in Ant: delete plain jar) -->
283-
<delete file="${project.build.directory}/${project.build.finalName}.jar"/>
284-
<move file="${project.build.directory}/${project.build.finalName}-wrapped.jar"
285-
tofile="${project.build.directory}/${project.build.finalName}.jar"/>
286-
</target>
287-
</configuration>
288-
<goals>
289-
<goal>run</goal>
290-
</goals>
291-
</execution>
292278
</executions>
293279
</plugin>
294280
<plugin>

0 commit comments

Comments
 (0)