jnr / jffi

Java Foreign Function Interface
Apache License 2.0
168 stars 78 forks source link

Incorrect version of native library? #93

Open jirutka opened 3 years ago

jirutka commented 3 years ago

The latest jffi has been released as 1.3.1, but native jffi library is still on 1.2.8 (defined in version.xml). Is this intentional or a mistake?

headius commented 3 years ago

Ah no, I guess I was unaware of that file needing to be updated. It should reflect the same version.

headius commented 3 years ago

I updated this so it will match for 1.3.2 but this is just a temporary fix... we need to get this version sourced from the same place as the Maven build or it will get stale again.

headius commented 3 years ago

I have to revert this because the prebuilt JNI stubs all are set up with the old "1.2" version, so changing this manually will cause them to not be found and we will unpack new versions of them.

I will open a PR to fix the versioning issue correctly, but it will be messy.

headius commented 3 years ago

Here is a diff I started to do this, but I think we should look into the maven native plugin and helper library for doing this, rather than having all these weird builds and version numbers floating around:

diff --git a/pom.xml b/pom.xml
index fc3258d..b57b69e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -224,6 +224,7 @@
                 <property name="dist.dir" value="${project.build.directory}" />
                 <property name="build.dir" value="${project.build.directory}" />
                 <property name="build.classes.dir" value="${project.build.outputDirectory}" />
+                <property name="jffi.version" value="${project.version}" />
                 <ant antfile="version.xml" dir="." target="-generate-version-source" />
               </tasks>
               <sourceRoot>
diff --git a/version.xml b/version.xml
index 14889e3..9a99cfe 100644
--- a/version.xml
+++ b/version.xml
@@ -1,7 +1,4 @@
 <project name="version" default="default" basedir=".">
-    <property name="jffi.version.major" value="1"/>
-    <property name="jffi.version.minor" value="3"/>
-    <property name="jffi.version.micro" value="2"/>
     <target name="-generate-version-source" depends="">
         <echo message="Generating Version.java"/>
         <mkdir dir="${build.classes.dir}"/>
@@ -12,11 +9,16 @@
             public final class Version {
                 private Version() {}
                 @Native
-                public static final int MAJOR = ${jffi.version.major};
+                public static final String VERSION = "${jffi.version}".replace("-SNAPSHOT", "");
+
+                private static final String[] VERSION_COMPONENTS = VERSION.split(".");
+
                 @Native
-                public static final int MINOR = ${jffi.version.minor};
+                public static final int MAJOR = Integer.valueOf(VERSION_COMPONENTS[0]);
                 @Native
-                public static final int MICRO = ${jffi.version.micro};
+                public static final int MINOR = Integer.valueOf(VERSION_COMPONENTS[1]);
+                @Native
+                public static final int MICRO = Integer.valueOf(VERSION_COMPONENTS[2]);
             }
         </echo>
     </target>