You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/07/11 20:04:33 UTC

[activemq-artemis-native] 01/02: Using maven compile to generate the .h

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis-native.git

commit 352b319f01812cf04d0d50eda046cca3d6dbe90b
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Mon Jul 11 13:42:37 2022 -0400

    Using maven compile to generate the .h
---
 pom.xml                                                        | 10 ++++++++++
 src/main/c/CMakeLists.txt                                      |  6 ------
 .../apache/activemq/artemis/nativo/jlibaio/NativeLogger.java   |  5 ++++-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8d200ab..89ceeb8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -248,6 +248,16 @@
     <build>
         <pluginManagement>
             <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <configuration>
+                        <compilerArgs>
+                            <arg>-h</arg>
+                            <arg>./src/main/c</arg>
+                        </compilerArgs>
+                    </configuration>
+                </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
diff --git a/src/main/c/CMakeLists.txt b/src/main/c/CMakeLists.txt
index 631156a..d457235 100644
--- a/src/main/c/CMakeLists.txt
+++ b/src/main/c/CMakeLists.txt
@@ -70,12 +70,6 @@ message(STATUS "Using the following libaio library for linking: ${LIBAIO_LIB}")
 
 INCLUDE_DIRECTORIES(. ${JNI_INCLUDE_DIRS})
 
-ADD_CUSTOM_COMMAND(
-    OUTPUT org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.h
-    COMMAND javac -h . ../java/org/apache/activemq/artemis/nativo/jlibaio/LibaioContext.java  -cp ../java/ -d ../../../target/classes-javah-compilation
-    DEPENDS ../java/org/apache/activemq/artemis/nativo/jlibaio/LibaioContext.java
-)
-
 ADD_LIBRARY(artemis-native SHARED org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.h exception_helper.h)
 
 target_link_libraries(artemis-native ${LIBAIO_LIB})
diff --git a/src/main/java/org/apache/activemq/artemis/nativo/jlibaio/NativeLogger.java b/src/main/java/org/apache/activemq/artemis/nativo/jlibaio/NativeLogger.java
index c5ddd81..ad14bdc 100644
--- a/src/main/java/org/apache/activemq/artemis/nativo/jlibaio/NativeLogger.java
+++ b/src/main/java/org/apache/activemq/artemis/nativo/jlibaio/NativeLogger.java
@@ -16,6 +16,9 @@
  */
 package org.apache.activemq.artemis.nativo.jlibaio;
 
+/** Notice: After making changes to the native interface, you have to use mvn install at least once to generate the .h
+ *          This is because the maven compiler plugin is the one generating org_apache_activemq_artemis_native_jlibaio_LibaioContext.h
+ *          So that file needs to be updated before Cmake comes along to compile the module. */
 public class NativeLogger {
 
    public static final String PROJECT_PREFIX = "jlibaio";
@@ -26,7 +29,7 @@ public class NativeLogger {
       loggerCallback = callback;
    }
 
-   private static final int DIFFERENT_VERSION_ID = 163001;
+   private static final int DIFFERENT_VERSION_ID = 163002;
    private static final String DIFFERENT_VERSION = PROJECT_PREFIX + DIFFERENT_VERSION_ID + " You have a native library with a different version than expected";
 
    public final static void incompatibleNativeLibrary() {