Initial commit of fully mavenized build
authorJakub Skoczen <jakub@indexdata.dk>
Tue, 16 Feb 2010 16:11:38 +0000 (17:11 +0100)
committerJakub Skoczen <jakub@indexdata.dk>
Tue, 16 Feb 2010 16:11:38 +0000 (17:11 +0100)
Instead of make, maven native plugin is used to build the C/C++ JNI wrapper interface. This will make it easier to introduce proper win32 support and architecure dependend JARs to ease dependency management of client projects.

The win32 pom.xml is not yet included.

The arch-dep build can be activated by invoking 'linux' profile:

mvn package -Plinux

17 files changed:
AUTHORS [deleted file]
README [deleted file]
any/pom.xml [new file with mode: 0644]
libyaz4j/Makefile [deleted file]
libyaz4j/build-windows.bat [deleted file]
libyaz4j/include/zoom-extra.h [deleted file]
libyaz4j/lib/.gitignore [deleted file]
libyaz4j/libyaz4j.i [deleted file]
libyaz4j/obj/.gitignore [deleted file]
libyaz4j/src/.gitignore [deleted file]
libyaz4j/src/zoom-extra.cpp [deleted file]
linux/pom.xml [new file with mode: 0644]
pom.xml
src/main/java/org/yaz4j/jni/.gitignore [deleted file]
src/main/native/zoom-extra.cpp [new file with mode: 0644]
src/main/native/zoom-extra.h [new file with mode: 0644]
src/main/swig/libyaz4j.i [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644 (file)
index e310170..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,5 +0,0 @@
-Rob Styles <Rob.Styles@talis.com>
-Adam Dickmeiss <adam@indexdata.dk>
-J. Cayetano <juancayetano.delgado@gmail.com>
-
-
diff --git a/README b/README
deleted file mode 100644 (file)
index 00262cd..0000000
--- a/README
+++ /dev/null
@@ -1,25 +0,0 @@
-yaz4j is a Java wrapper for the ZOOM API of YAZ. This allows developers
-to write Z39.50 clients in Java.
-
-yaz4j is distributed under the revised BSD license.
-
-Copyright (C) 2006-2007, Talis.
-Copyright (C) 2008-2009, Index Data.
-See LICENSE for details.
-
-In order to built yaz4j the Java JDK, Maven, YAZ and Swig must be installed.
-The exact process varies from platform to platform.
-
-For example, on Ubuntu/Debian the following installs the components:
-  apt-get install sun-java6-jdk maven2 libyaz3-dev swig
-
-The compilation for native code (JNI) is performed by good old make.
-Adjust libyaz4j/Makefile as necessary. Tune JAVA_HOME and perhaps path to
-yaz-config in the Makefile.
-
-The Maven pom.xml will automatically invoke libyaz4j/Makefile , so
-this is what it takes:
-  mvn compile
-
-If you network-connected you should be able to run tests with:
-  mvn test
diff --git a/any/pom.xml b/any/pom.xml
new file mode 100644 (file)
index 0000000..b174c55
--- /dev/null
@@ -0,0 +1,43 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.yaz4j</groupId>
+    <artifactId>yaz4j</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>yaz4j-any</artifactId>
+  <name>yaz4j-any</name>
+  <packaging>jar</packaging>
+
+  <build>
+    <sourceDirectory>../src/main/java</sourceDirectory>
+    <plugins>
+     <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>include-generated-sources</id>
+            <phase>generate-sources</phase>
+            <goals><goal>add-source</goal></goals>
+            <configuration>
+              <sources><source>../target/generated-sources/java</source></sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <encoding>UTF-8</encoding>
+          <source>1.6</source>
+          <target>1.6</target>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/libyaz4j/Makefile b/libyaz4j/Makefile
deleted file mode 100644 (file)
index bc34ec7..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-JNI_DIR=/usr/lib/jvm/java-6-sun/include
-YAZ_CONFIG=yaz-config
-YAZ_PREFIX=`${YAZ_CONFIG} --prefix`
-YAZ_CFLAGS=`${YAZ_CONFIG} --cflags`
-YAZ_LIBS=`${YAZ_CONFIG} --libs`
-
-all: lib/libyaz4j.so
-
-.PHONY: generate-sources
-
-generate-sources: src/libyaz4j.cpp
-
-src/libyaz4j.cpp: libyaz4j.i
-       swig -I"include" -I"$(YAZ_PREFIX)/include" -outdir ../src/main/java/org/yaz4j/jni -package org.yaz4j.jni -o src/libyaz4j.cpp -c++ -java libyaz4j.i
-
-obj/libyaz4j.o: src/libyaz4j.cpp
-       g++ -fPIC -I"include" -I"$(JNI_DIR)" -I"$(JNI_DIR)/linux" $(YAZ_CFLAGS) -c -Wall -o obj/libyaz4j.o src/libyaz4j.cpp
-
-obj/zoom-extra.o: src/zoom-extra.cpp
-       g++ -fPIC -I"include" -I"$(JNI_DIR)" -I"$(JNI_DIR)/linux" $(YAZ_CFLAGS) -c -Wall -o obj/zoom-extra.o src/zoom-extra.cpp
-
-lib/libyaz4j.so: obj/zoom-extra.o obj/libyaz4j.o
-       g++ -shared obj/libyaz4j.o obj/zoom-extra.o  -o lib/libyaz4j.so $(YAZ_LIBS)
-
-clean:
-       rm -f obj/*.o lib/libyaz4j.* src/libyaz4j.cpp ../src/main/java/org/yaz4j/jni/*.java
diff --git a/libyaz4j/build-windows.bat b/libyaz4j/build-windows.bat
deleted file mode 100644 (file)
index 3b719cf..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-@echo .
-@echo .NET Framework 2.0 Software Development Kit (SDK) (x86) or equilavent framework must be installed
-@echo This batch file should be called from a DOS command prompt
-@echo .
-@echo Before calling 'yaz4j.dll' ensure the yaz bin directory (e.g. yaz_3.0.14\bin) is added to the Windows system 'path'
-@echo .
-
-@echo .
-@echo **********************
-@echo **** SETTING PATH ****
-set path=%path%;C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
-
-@echo .
-@echo **************
-@echo **** SWIG ****
-E:/General/Software/Swig/swigwin-1.3.31/swig.exe -I"include" -I"..\dependencies\yaz_3.0.14\include\yaz" -outdir "..\src\org\yaz4j\jni" -package org.yaz4j.jni -o "src\libyaz4j.cpp" -c++ -java libyaz4j.i
-
-@echo If have SWIG errors (e.g. Syntax error in input) the cpp file may still be created correctly
-
-@echo .
-@echo ***************************
-@echo **** Compiling (yaz4j) ****
-cl -c /Gz "/IC:\Program Files\Microsoft Visual Studio 8\VC\include" "/I.\include" "/I..\dependencies\yaz_3.0.14\include" "/I..\dependencies\yaz_3.0.14\include\yaz" "/IC:\Program Files\java\jdk1.5.0_07\include" "/IC:\Program Files\java\jdk1.5.0_07\include\win32" /Fo"obj\yaz4j.obj" "src\libyaz4j.cpp"
-
-@echo .
-@echo ********************************
-@echo **** Compiling (zoom-extra) ****
-cl -c /Gz "/IC:\Program Files\Microsoft Visual Studio 8\VC\include" "/I.\include" "/I..\dependencies\yaz_3.0.14\include" "/I..\dependencies\yaz_3.0.14\include\yaz" "/IC:\Program Files\java\jdk1.5.0_07\include" "/IC:\Program Files\java\jdk1.5.0_07\include\win32" /Fo"obj\zoom-extra.obj" "src\zoom-extra.cpp"
-
-@echo .
-@echo *****************
-@echo **** Linking ****
-link "/LIBPATH:C:\Program Files\Microsoft Visual Studio 8\VC\lib" "/DEFAULTLIB:..\dependencies\yaz_3.0.14\lib\yaz3.lib" "/OUT:lib\yaz4j.dll" "obj\zoom-extra.obj" "obj\yaz4j.obj" /dll
-IF EXIST ".\lib\yaz4j.exp". del ".\lib\yaz4j.exp"
-IF EXIST ".\lib\yaz4j.lib". del ".\lib\yaz4j.lib"
-
-
-
-
-
-@echo off
-
-rem -------------- notes only ------------------------
-
-rem .NET Framework 2.0 Software Development Kit (SDK) (x86)
-rem http://www.microsoft.com/downloads/details.aspx?familyid=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displaylang=en
-
-rem C++ options:
-rem http://msdn2.microsoft.com/en-us/library/91621w01(VS.80).aspx
-
-rem Compiler options:
-rem http://msdn2.microsoft.com/en-us/library/19z1t1wy(VS.80).aspx
-
-rem Linker options:
-rem http://msdn2.microsoft.com/en-us/library/y0zzbyt4(VS.80).aspx
-
-rem Tried to do above using g++ but could not get the last (link) stage to work, so used microsoft compiler as above
-rem E:/General/Software/Swig/swigwin-1.3.31/swig.exe -I"..\dependencies\yaz_3.0.14\include\yaz" -outdir "..\src\org\yaz4j\jni" -package org.yaz4j.jni -o "src\libyaz4j.cpp" -c++ -java libyaz4j.i
-rem g++ -I"..\dependencies\yaz_3.0.14\include" -I"..\dependencies\yaz_3.0.14\include\yaz" -I"C:\Program Files\java\jdk1.5.0_13\include" -I"C:\Program Files\java\jdk1.5.0_13\include\win32" -g3 -O0 -Wall -c -o "obj\libyaz4j.o" "src\libyaz4j.cpp"
-rem g++ -L"..\dependencies\yaz_3.0.14\lib" -shared "obj\libyaz4j.o" -l"yaz3" -mno-cygwin -Wl,--add-stdcall-alias -Wall -o "lib\yaz4jlib.dll"
-
-rem #strings "obj\libyaz4j.o"
-
-@echo on
\ No newline at end of file
diff --git a/libyaz4j/include/zoom-extra.h b/libyaz4j/include/zoom-extra.h
deleted file mode 100644 (file)
index 6d428a8..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef INCLUDED_WRAPPER
-#define INCLUDED_WRAPPER
-#include <yaz/zoom.h>
-struct CharStarByteArray
-{
-       char* data;
-       long length;
-};
-struct CharStarByteArray ZOOM_record_get_bytes(ZOOM_record rec, const char *type, int *len);
-#endif
-
diff --git a/libyaz4j/lib/.gitignore b/libyaz4j/lib/.gitignore
deleted file mode 100644 (file)
index 140f8cf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-*.so
diff --git a/libyaz4j/libyaz4j.i b/libyaz4j/libyaz4j.i
deleted file mode 100644 (file)
index 61e4693..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-%javaconst(1);
-%module yaz4jlib
-       %{
-               #include "zoom-extra.h"
-               #include <yaz/zoom.h>
-       %}
-       %include "typemaps.i"
-       %include "arrays_java.i"
-       %include "cpointer.i"
-       %pointer_functions(int, intp);
-       %pointer_functions(size_t, size_tp);
-       %typemap(jni) CharStarByteArray "jbyteArray"
-       %typemap(jtype) CharStarByteArray "byte[]"
-       %typemap(jstype) CharStarByteArray "byte[]"
-       %typemap(out) CharStarByteArray {
-               $result = SWIG_JavaArrayOutSchar(jenv, (signed char*) $1.data, $1.length);
-               free((void*)$1.data);
-       }
-       %typemap(javaout) CharStarByteArray { return $jnicall; }
-       %define YAZ_BEGIN_CDECL %enddef
-       %define YAZ_END_CDECL %enddef
-       %include "zoom-extra.h"
-       %include <yaz/zoom.h>
-
diff --git a/libyaz4j/obj/.gitignore b/libyaz4j/obj/.gitignore
deleted file mode 100644 (file)
index c395c62..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-*.o
-*.obj
diff --git a/libyaz4j/src/.gitignore b/libyaz4j/src/.gitignore
deleted file mode 100644 (file)
index aaa2ff3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-libyaz4j.cpp
diff --git a/libyaz4j/src/zoom-extra.cpp b/libyaz4j/src/zoom-extra.cpp
deleted file mode 100644 (file)
index 0521686..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "zoom-extra.h"
-#include <string.h>
-
-struct CharStarByteArray ZOOM_record_get_bytes(ZOOM_record rec, const char *type, int *len)
-{
-       struct CharStarByteArray node;
-       const char* pageData = ZOOM_record_get(rec, type, len);
-       node.length = strlen(pageData);
-       node.data = (char*) malloc(node.length+1);
-       strcpy(node.data, pageData);
-       return node;
-}
diff --git a/linux/pom.xml b/linux/pom.xml
new file mode 100644 (file)
index 0000000..aedbef8
--- /dev/null
@@ -0,0 +1,175 @@
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.yaz4j</groupId>
+    <artifactId>yaz4j</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <groupId>org.yaz4j</groupId>
+  <artifactId>libyaz4j</artifactId>
+  <name>libyaz4j</name>
+  <packaging>so</packaging>
+
+  <build>
+    <finalName>${artifactId}</finalName>
+    <testSourceDirectory>../src/test</testSourceDirectory>
+
+    <plugins>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>write-yaz-config</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <exec executable="yaz-config" outputproperty="yaz.cflags">
+                  <arg value="--cflags" />
+                </exec>
+                <echo message="YAZ CFLAGS: ${yaz.cflags}"/>
+                <exec executable="yaz-config" outputproperty="yaz.libs">
+                  <arg value="--libs" />
+                </exec>
+                <echo message="YAZ LIBS: ${yaz.libs}"/>
+                <!-- this does not work on debian/ubuntu
+                <propertyfile file="${basedir}/target/yaz-config.properties"
+                  comment="YAZ COMPILER/LINKER FLAGS">
+                  <entry key="yaz.cflags" value="${yaz.cflags}"/>
+                  <entry key="yaz.libs" value="${yaz.libs}"/>
+                </propertyfile>
+                -->
+                <echo file="${basedir}/target/yaz-config.properties"
+                  message="yaz.cflags=${yaz.cflags}${line.separator}yaz.libs=${yaz.libs}"/>
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>properties-maven-plugin</artifactId>
+        <version>1.0-alpha-1</version>
+        <executions>
+          <execution>
+            <id>read-yaz-config</id>
+            <phase>initialize</phase>
+            <goals>
+              <goal>read-project-properties</goal>
+            </goals>
+            <configuration>
+              <files>
+                <file>${basedir}/target/yaz-config.properties</file>
+              </files>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>native-maven-plugin</artifactId>
+        <extensions>true</extensions>       
+        <configuration>         
+          <javahOS>linux</javahOS>
+          <compilerProvider>generic</compilerProvider>
+          <compilerExecutable>g++</compilerExecutable>
+          <compilerStartOptions>
+            <compilerStartOption>-fPIC</compilerStartOption>
+          </compilerStartOptions>
+          <compilerEndOptions>
+            <compilerEndOption>${yaz.cflags}</compilerEndOption>
+          </compilerEndOptions>
+          <sources>
+            <source>
+              <includes>
+                <include>**/*.cpp</include>
+              </includes>
+              <directory>../src/main/native</directory>
+            </source>
+            <source>
+              <includes>
+                <include>**/*.cpp</include>
+              </includes>
+              <directory>../target/generated-sources/native</directory>
+            </source>
+          </sources>
+          <linkerExecutable>g++</linkerExecutable>
+          <linkerStartOptions>
+            <linkerStartOption>-shared</linkerStartOption>
+          </linkerStartOptions>
+          <linkerEndOptions>
+            <linkerEndOption>${yaz.libs}</linkerEndOption>
+          </linkerEndOptions>
+        </configuration>
+      </plugin>
+
+      <!-- this is to compile and execute tests, that are arch-dependent
+       because they need to load so/dll -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <encoding>UTF-8</encoding>
+          <source>1.6</source>
+          <target>1.6</target>
+          <showDeprecation>true</showDeprecation>
+          <showWarnings>true</showWarnings>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>include-generated-test-sources</id>
+            <phase>generate-test-sources</phase>
+            <goals><goal>add-test-source</goal></goals>
+            <configuration>
+              <sources>
+                <source>../src/main/java</source>
+                <source>../target/generated-sources/java</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkMode>once</forkMode>
+          <workingDirectory>target</workingDirectory>
+          <argLine>-Djava.library.path=${project.build.directory}</argLine>
+        </configuration>
+      </plugin>
+    </plugins>    
+  </build>
+
+  <repositories>
+    <repository>
+      <id>Codehaus Snapshots</id>
+      <url>http://snapshots.repository.codehaus.org/</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+    </repository>
+  </repositories>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>Codehaus Snapshots</id>
+      <url>http://snapshots.repository.codehaus.org/</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+        <enabled>true</enabled>  <!-- Workaround for MNG-2974, see note below -->
+      </releases>
+    </pluginRepository>
+  </pluginRepositories>
+</project>
diff --git a/pom.xml b/pom.xml
index 399ec8a..f087ae5 100644 (file)
--- a/pom.xml
+++ b/pom.xml
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-    <!-- POM Relationships -->
-    <modelVersion>4.0.0</modelVersion>
-    <groupId>org.yaz4j</groupId>
-    <artifactId>yaz4j</artifactId>
-    <version>1.1-snapshot</version>
-    <packaging>jar</packaging>
-
-    <!-- Project Information -->
-    <name>yaz4j</name>
-    <url>http://www.indexdata.com/yaz4j/</url>
-    <inceptionYear>2008</inceptionYear>
-    <licenses>
-        <license>
-            <name>BSD</name>
-            <url>http://www.opensource.org/licenses/bsd-license.php</url>
-        </license>
-    </licenses>
-    <description>Java wrapper for the ZOOM API of YAZ</description>
-
-    <developers>
-        <developer>
-            <name>Rob Styles</name>
-            <id>rob</id>
-            <email>Rob.Styles@talis.com</email>
-            <organization>Talis</organization>
-            <organizationUrl>http://www.talis.com/</organizationUrl>
-            <roles />
-            <timezone />
-        </developer>
-        <developer>
-            <name>Adam Dickmeiss</name>
-            <id>adam</id>
-            <email>adam@indexdata.dk</email>
-            <organization>Index Data</organization>
-            <organizationUrl>http://www.indexdata.com/</organizationUrl>
-            <roles />
-            <timezone />
-        </developer>
-        <developer>
-            <name>Juan Cayetano</name>
-            <id>cayetano</id>
-            <email>juancayetano.delgado@gmail.com</email>
-            <organization />
-            <organizationUrl />
-            <roles />
-            <timezone />
-        </developer>
-    </developers>
-    <!-- ///////////////// -->
-
-    <!-- Project Dependencies -->
-    <dependencies>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.3.1</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-    <!-- ///////////////// -->
-
-    <!-- Build Settings -->
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-resources-plugin</artifactId>
-                <configuration>
-                    <encoding>UTF-8</encoding>
-                </configuration>
-            </plugin>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <encoding>UTF-8</encoding>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                    <showDeprecation>true</showDeprecation>
-                    <showWarnings>true</showWarnings>
-                </configuration>
-            </plugin>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <forkMode>once</forkMode>
-                    <workingDirectory>target</workingDirectory>
-                    <argLine>-Djava.library.path=${basedir}/libyaz4j/lib</argLine>
-                </configuration>
-            </plugin>
-
-           <plugin>
-             <artifactId>maven-antrun-plugin</artifactId>
-             <executions>
-               <execution>
-                 <id>native-sources</id>
-                 <phase>generate-sources</phase>
-                 <goals>
-                   <goal>run</goal>
-                 </goals>
-                 <configuration>
-                   <tasks>
-                     <exec dir="libyaz4j" executable="make" failonerror="true">
-                       <arg value="generate-sources"/>
-                     </exec>
-                   </tasks>
-                 </configuration>
-               </execution>
-
-               <execution>
-                 <id>build-native</id>
-                 <phase>compile</phase>
-                 <goals>
-                   <goal>run</goal>
-                 </goals>
-                 <configuration>
-                   <tasks>
-                     <exec dir="libyaz4j" executable="make" failonerror="true">
-                       <arg value="all"/>
-                     </exec>
-                   </tasks>
-                 </configuration>
-               </execution>
-               
-               <execution>
-                 <id>clean-native</id>
-                 <phase>clean</phase>
-                 <goals>
-                   <goal>run</goal>
-                 </goals>
-                 <configuration>
-                   <tasks>
-                     <exec dir="libyaz4j" executable="make" failonerror="true">
-                       <arg value="clean"/>
-                     </exec>
-                   </tasks>
-                 </configuration>
-               </execution>
-             </executions>
-           </plugin>
-
-        </plugins>
-    </build>
-
-    <!-- Reporting -->
-    <reporting>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <enableRSS>false</enableRSS>
-                    <include>**/*.java</include>
-                    <sourceDirectory>src/main/java</sourceDirectory>
-                </configuration>
-            </plugin>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>
-                maven-project-info-reports-plugin
-                </artifactId>
-                <reportSets>
-                    <reportSet>
-                        <reports>
-                            <report>dependencies</report>
-                            <report>project-team</report>
-                            <report>mailing-list</report>
-                            <report>issue-tracking</report>
-                            <report>summary</report>
-                            <report>scm</report>
-                            <report>index</report>
-                        </reports>
-                    </reportSet>
-                </reportSets>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <configuration>
-                    <chartset>UTF-8</chartset>
-                </configuration>
-            </plugin>
-        </plugins>
-    </reporting>
-    <!-- ////////////// -->
-
-    <!-- Build Environment -->
-    <!-- Environment Information -->
-    <mailingLists>
-        <mailingList>
-            <name>Yazlist</name>
-            <subscribe />
-            <unsubscribe />
-            <post>yazlist@lists.indexdata.dk</post>
-            <archive>http://lists.indexdata.dk/pipermail/yazlist/</archive>
-        </mailingList>
-    </mailingLists>
-
-    <scm>
-        <connection>scm:git:git://git.indexdata.com/yaz4j</connection>
-        <url>http://git.indexdata.com/?p=yaz4j.git</url>
-    </scm>
-
-    <issueManagement>
-        <system>Bugzilla</system>
-        <url>http://bugzilla.indexdata.dk</url>
-    </issueManagement>
-
-    <ciManagement>
-        <system />
-        <url />
-    </ciManagement>
-    <!-- /////////////////////// -->
-
-    <!-- Maven Environment -->
-    <repositories />
-    <pluginRepositories />
-    <!-- ///////////////// -->
-
-    <!-- Maven Common Properties -->
-    <properties />
-    <!-- /////////////////// -->
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.yaz4j</groupId>
+  <artifactId>yaz4j</artifactId>
+  <name>yaz4j</name>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>any</module>
+  </modules>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.3.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-sources</id>
+            <phase>generate-sources</phase>
+            <inherited>false</inherited>
+            <configuration>
+              <tasks>
+                <exec executable="yaz-config" outputproperty="yaz.prefix">
+                  <arg value="--prefix" />              
+                </exec>
+                <echo message="Using yaz prefix: ${yaz.prefix}"/>
+                <mkdir dir="target/generated-sources/java/org/yaz4j/jni"/>
+                <mkdir dir="target/generated-sources/native" />
+                <exec executable="swig">
+                  <arg value="-Isrc/main/native" />
+                  <arg value="-I${yaz.prefix}/include"/>
+                  <arg value="-outdir"/>
+                  <arg value="${basedir}/target/generated-sources/java/org/yaz4j/jni"/>
+                  <arg value="-package"/>
+                  <arg value="org.yaz4j.jni"/>
+                  <arg value="-o"/>
+                  <arg value="${basedir}/target/generated-sources/native/libyaz4j.cpp"/>
+                  <arg value="-c++"/>
+                  <arg value="-java"/>
+                  <arg value="src/main/swig/libyaz4j.i"/>
+                </exec>
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+   </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>win32</id>
+      <activation>
+        <property>
+          <name>platform</name>
+          <value>win32</value>
+        </property>
+      </activation>
+      <modules>
+        <module>win32</module>
+      </modules>
+    </profile>
+
+    <profile>
+      <id>linux</id>
+      <activation>
+        <property>
+          <name>platform</name>
+          <value>linux</value>
+        </property>
+      </activation>
+      <modules>
+        <module>linux</module>
+      </modules>
+    </profile>
+ </profiles>
 </project>
 
-
diff --git a/src/main/java/org/yaz4j/jni/.gitignore b/src/main/java/org/yaz4j/jni/.gitignore
deleted file mode 100644 (file)
index 27d1535..0000000
+++ /dev/null
@@ -1 +0,0 @@
-*.java
diff --git a/src/main/native/zoom-extra.cpp b/src/main/native/zoom-extra.cpp
new file mode 100644 (file)
index 0000000..0521686
--- /dev/null
@@ -0,0 +1,12 @@
+#include "zoom-extra.h"
+#include <string.h>
+
+struct CharStarByteArray ZOOM_record_get_bytes(ZOOM_record rec, const char *type, int *len)
+{
+       struct CharStarByteArray node;
+       const char* pageData = ZOOM_record_get(rec, type, len);
+       node.length = strlen(pageData);
+       node.data = (char*) malloc(node.length+1);
+       strcpy(node.data, pageData);
+       return node;
+}
diff --git a/src/main/native/zoom-extra.h b/src/main/native/zoom-extra.h
new file mode 100644 (file)
index 0000000..6d428a8
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef INCLUDED_WRAPPER
+#define INCLUDED_WRAPPER
+#include <yaz/zoom.h>
+struct CharStarByteArray
+{
+       char* data;
+       long length;
+};
+struct CharStarByteArray ZOOM_record_get_bytes(ZOOM_record rec, const char *type, int *len);
+#endif
+
diff --git a/src/main/swig/libyaz4j.i b/src/main/swig/libyaz4j.i
new file mode 100644 (file)
index 0000000..61e4693
--- /dev/null
@@ -0,0 +1,24 @@
+%javaconst(1);
+%module yaz4jlib
+       %{
+               #include "zoom-extra.h"
+               #include <yaz/zoom.h>
+       %}
+       %include "typemaps.i"
+       %include "arrays_java.i"
+       %include "cpointer.i"
+       %pointer_functions(int, intp);
+       %pointer_functions(size_t, size_tp);
+       %typemap(jni) CharStarByteArray "jbyteArray"
+       %typemap(jtype) CharStarByteArray "byte[]"
+       %typemap(jstype) CharStarByteArray "byte[]"
+       %typemap(out) CharStarByteArray {
+               $result = SWIG_JavaArrayOutSchar(jenv, (signed char*) $1.data, $1.length);
+               free((void*)$1.data);
+       }
+       %typemap(javaout) CharStarByteArray { return $jnicall; }
+       %define YAZ_BEGIN_CDECL %enddef
+       %define YAZ_END_CDECL %enddef
+       %include "zoom-extra.h"
+       %include <yaz/zoom.h>
+