Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
<property name="forbidden-apis.available" value="true"/>
</target>

<target name="install-bnd" unless="bnd.available">
<!-- using bnd 1.50.0 because more recent versions have broken JAR wrapping -->
<ivy:cachepath organisation="biz.aQute" module="bnd" revision="1.50.0"
inline="true" conf="default" transitive="true" pathid="bnd.classpath"/>
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="bnd.classpath"/>
<property name="bnd.available" value="true"/>
</target>

<target name="init">
<tstamp />
<ivy:resolve conf="test" />
Expand Down Expand Up @@ -270,7 +278,7 @@
<target name="jar" description="generate JAR" depends="compile">
<mkdir dir="${dist}" />
<jar
destfile="${dist}/${ivy.module}-${ivy.revision}.jar">
destfile="${dist}/${ivy.module}.jar">
<fileset dir="${src}/resources" erroronmissingdir="false" />
<fileset dir="${build}/classes" />
<fileset dir="${build}/unsafe-classes" />
Expand All @@ -279,6 +287,25 @@
</jar>
</target>

<target name="bundle" description="makes the JAR a valid OSGi bundle" depends="install-bnd, jar">
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="bnd.classpath"/>
<property name="packages.version" value="${ivy.revision}"/>
<!-- We need to remove potential -SNAPSHOT qualifiers as package versions... -->
<script language="javascript">
<![CDATA[
// lz4 is the ant project name
version = lz4.getProperty("packages.version");
lz4.setProperty("packages.version", version.replace("-SNAPSHOT", ""));
]]>
</script>
<!-- wrap the JAR as a bundle and set the proper name -->
<bndwrap definitions="${basedir}" output="${dist}/${ivy.module}-${ivy.revision}.jar" trace="true">
<fileset dir="${dist}/" includes="${ivy.module}.jar"/>
</bndwrap>
<!-- remove plain JAR -->
<delete file="${dist}/${ivy.module}.jar"/>
</target>

<target name="makepom" description="generate a pom file">
<ivy:makepom
ivyfile="${basedir}/ivy.xml"
Expand All @@ -289,7 +316,7 @@
</ivy:makepom>
</target>

<target name="dist" description="package" depends="jar,docs,sources,makepom" />
<target name="dist" description="package" depends="bundle,docs,sources,makepom" />

<target name="forbidden-apis" description="check API usage" depends="install-forbidden-apis,compile">
<forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.classpath">
Expand Down
5 changes: 5 additions & 0 deletions lz4.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bundle-SymbolicName: lz4-java
Bundle-Name: LZ4 Java Compression
Bundle-Version:${ivy.revision}
Export-Package: net.jpountz.*;version:=${packages.version}

2 changes: 1 addition & 1 deletion src/java/net/jpountz/lz4/LZ4Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static LZ4Factory fastestInstance() {

@SuppressWarnings("unchecked")
private static <T> T classInstance(String cls) throws NoSuchFieldException, SecurityException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException {
final Class<?> c = Class.forName(cls);
final Class<?> c = LZ4Factory.class.getClassLoader().loadClass(cls);
Field f = c.getField("INSTANCE");
return (T) f.get(null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/java/net/jpountz/xxhash/XXHashFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static XXHashFactory fastestInstance() {

@SuppressWarnings("unchecked")
private static <T> T classInstance(String cls) throws NoSuchFieldException, SecurityException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException {
final Class<?> c = Class.forName(cls);
final Class<?> c = XXHashFactory.class.getClassLoader().loadClass(cls);
Field f = c.getField("INSTANCE");
return (T) f.get(null);
}
Expand Down