[jffi-next] 15/49: Coerce maven into bundling up the native libs into an artifact attachment which can be used by downstream projects.
Tim Potter
tpot-guest at moszumanska.debian.org
Wed Mar 4 04:51:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
tpot-guest pushed a commit to annotated tag upstream/1.0.10
in repository jffi-next.
commit bca5b3a94ac71283b81537faa7e720189d9b0841
Author: Wayne Meissner <wmeissner at gmail.com>
Date: Fri Jan 21 19:54:53 2011 +1000
Coerce maven into bundling up the native libs into an artifact attachment which can be used by downstream projects.
---
native-assemble.xml | 20 +++++++++++++++
pom.xml | 55 ++++++++++++++++++++++++++++++++++++++++-
src/com/kenai/jffi/Foreign.java | 6 ++---
src/com/kenai/jffi/Init.java | 12 ++++-----
4 files changed, 83 insertions(+), 10 deletions(-)
diff --git a/native-assemble.xml b/native-assemble.xml
new file mode 100644
index 0000000..59b7f18
--- /dev/null
+++ b/native-assemble.xml
@@ -0,0 +1,20 @@
+<assembly>
+ <id>native</id>
+ <formats>
+ <format>jar</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.directory}/jni</directory>
+ <outputDirectory>/jni</outputDirectory>
+ <includes>
+ <include>**/*.dll</include>
+ <include>**/*.so</include>
+ <include>**/*.jnilib</include>
+ <include>**/*.dylib</include>
+ <include>**/*.a</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 56d64fc..9a84cd6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>org.jruby.extras</groupId>
<artifactId>jffi</artifactId>
<packaging>jar</packaging>
- <version>1.0.4</version>
+ <version>1.0.5-SNAPSHOT</version>
<name>jffi</name>
<description>Java wrapper around libffi</description>
<url>http://github.com/wmeissner/jffi</url>
@@ -167,6 +167,59 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <unzip dest="${project.build.directory}/" overwrite="true">
+ <patternset>
+ <include name="**/*.so"/>
+ <include name="**/*.dylib"/>
+ <include name="**/*.jnilib"/>
+ <include name="**/*.dll"/>
+ <include name="**/*.a"/>
+ </patternset>
+ <fileset dir="archive">
+ <include name="**/*.jar"/>
+ </fileset>
+ </unzip>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <descriptors>
+ <descriptor>native-assemble.xml</descriptor>
+ </descriptors>
+ <archive>
+ <index>true</index>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ <executions>
+ <execution>
+ <id>native-assemble</id> <!-- this is used for inheritance merges -->
+ <phase>package</phase> <!-- append to the packaging phase. -->
+ <goals>
+ <goal>single</goal> <!-- goals == mojos -->
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<extensions>
<extension>
diff --git a/src/com/kenai/jffi/Foreign.java b/src/com/kenai/jffi/Foreign.java
index 96d877d..151d571 100644
--- a/src/com/kenai/jffi/Foreign.java
+++ b/src/com/kenai/jffi/Foreign.java
@@ -26,7 +26,7 @@ import java.nio.Buffer;
import java.nio.ByteBuffer;
final class Foreign {
-
+
private static abstract class InstanceHolder {
static final InstanceHolder INSTANCE = getInstanceHolder();
@@ -38,7 +38,7 @@ final class Foreign {
Foreign foreign = new Foreign();
if ((foreign.getVersion() & 0xffff00) != (VERSION_MAJOR << 16 | VERSION_MINOR << 8)) {
- throw new UnsatisfiedLinkError("Incorrect native library version");
+ return new InValidInstanceHolder(new UnsatisfiedLinkError("Incorrect native library version"));
}
foreign.init();
@@ -73,7 +73,7 @@ final class Foreign {
}
final Foreign getForeign() {
- throw cause;
+ throw new RuntimeException(cause);
}
}
diff --git a/src/com/kenai/jffi/Init.java b/src/com/kenai/jffi/Init.java
index 4a1ab34..a2cee6b 100644
--- a/src/com/kenai/jffi/Init.java
+++ b/src/com/kenai/jffi/Init.java
@@ -24,7 +24,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.Channels;
-import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;
@@ -149,7 +148,7 @@ final class Init {
System.load(dstFile.getAbsolutePath());
}
-
+
/**
* Gets an <tt>InputStream</tt> representing the stub library image stored in
* the jar file.
@@ -158,13 +157,14 @@ final class Init {
*/
private static final InputStream getStubLibraryStream() {
String path = getStubLibraryPath();
-
- InputStream is = Init.class.getResourceAsStream(path);
+ ClassLoader cl = Init.class.getClassLoader();
+ InputStream is = cl.getResourceAsStream(path);
// On MacOS, the stub might be named .dylib or .jnilib - cater for both
if (is == null && Platform.getPlatform().getOS() == Platform.OS.DARWIN) {
- is = Init.class.getResourceAsStream(path.replaceAll("dylib", "jnilib"));
+ is = cl.getResourceAsStream(path.replaceAll("dylib", "jnilib"));
}
+
if (is == null) {
throw new UnsatisfiedLinkError("Could not locate stub library ("
+ path + ") in jar file");
@@ -188,7 +188,7 @@ final class Init {
* @return The path of the jar file.
*/
private static final String getStubLibraryPath() {
- return "/jni/" + Platform.getPlatform().getName() + "/"+ System.mapLibraryName(stubLibraryName);
+ return "jni/" + Platform.getPlatform().getName() + "/"+ System.mapLibraryName(stubLibraryName);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git
More information about the pkg-java-commits
mailing list