diff --git a/.gitignore b/.gitignore
index 5f963ddd3f..71af624862 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,12 @@ ratReport.txt
.settings
.checkstyle
.factorypath
+
+# for native build
+**/CMakeCache.txt
+**/CMakeFiles/
+**/Makefile
+**/cmake_install.cmake
+
+# this file is generated
+artemis-native/src/main/c/org_apache_activemq_artemis_core_libaio_Native.h
diff --git a/artemis-native/CMakeLists.txt b/artemis-native/CMakeLists.txt
new file mode 100644
index 0000000000..06eb3b3079
--- /dev/null
+++ b/artemis-native/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SUBDIRS(src/main/c)
diff --git a/artemis-native/bin/libartemis-native-64.so b/artemis-native/bin/libartemis-native-64.so
index 1deebbca16..1c4983c9d3 100755
Binary files a/artemis-native/bin/libartemis-native-64.so and b/artemis-native/bin/libartemis-native-64.so differ
diff --git a/artemis-native/compile-native.sh b/artemis-native/compile-native.sh
index 7f89c955cf..22f4144bf5 100755
--- a/artemis-native/compile-native.sh
+++ b/artemis-native/compile-native.sh
@@ -15,4 +15,5 @@
# specific language governing permissions and limitations
# under the License.
-mvn install -Pnative-build
+cmake .
+make
diff --git a/artemis-native/pom.xml b/artemis-native/pom.xml
index 5b383c16eb..abd5f0de79 100644
--- a/artemis-native/pom.xml
+++ b/artemis-native/pom.xml
@@ -25,7 +25,7 @@
artemis-native
- ${native-package-type}
+ jar
org.apache.activemq
@@ -86,49 +86,8 @@
-
-
- native-build
-
- nar
-
-
-
-
- com.github.maven-nar
- nar-maven-plugin
- 3.0.0
- true
-
-
- true
-
-
-
-
-
-
-
-
- aio
-
-
-
-
-
- jni
- org.apache.activemq.artemis.core.libaio
-
-
-
-
-
-
-
-
- jar
${project.basedir}/..
diff --git a/artemis-native/src/main/c/CMakeLists.txt b/artemis-native/src/main/c/CMakeLists.txt
new file mode 100644
index 0000000000..0a45fd6870
--- /dev/null
+++ b/artemis-native/src/main/c/CMakeLists.txt
@@ -0,0 +1,79 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(artemis-native)
+SET(${PROJECT_NAME}_MAJOR_VERSION 1)
+SET(${PROJECT_NAME}_MINOR_VERSION 0)
+SET(${PROJECT_NAME}_PATCH_LEVEL 0)
+
+FIND_PACKAGE(Java)
+FIND_PACKAGE(JNI)
+if (JNI_FOUND)
+ message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
+ message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
+endif()
+
+# you may want to remove this next line for debugging
+# -O3 would make inline debug hard
+ADD_DEFINITIONS("-O3 -Wall")
+#ADD_DEFINITIONS("-fdump-tree-all -Wall -pg -g -mstack-protector-guard=guard")
+
+find_library(LIBAIO NAMES aio)
+
+INCLUDE_DIRECTORIES(. ${JNI_INCLUDE_DIRS})
+
+ADD_CUSTOM_COMMAND(
+ OUTPUT org_apache_activemq_artemis_core_libaio_Native.h
+ COMMAND javah -cp ../java/ org.apache.activemq.artemis.core.libaio.Native
+ DEPENDS ../java/org/apache/activemq/artemis/core/libaio/Native.java
+)
+
+ADD_LIBRARY(artemis-native SHARED
+ AIOController.cpp
+ AIOController.h
+ AIOException.h
+ AsyncFile.cpp
+ AsyncFile.h
+ CallbackAdapter.h
+ JAIODatatypes.h
+ JavaUtilities.cpp
+ JavaUtilities.h
+ JNI_AsynchronousFileImpl.cpp
+ JNICallbackAdapter.cpp
+ JNICallbackAdapter.h
+ LockClass.h
+ Version.h
+ org_apache_activemq_artemis_core_libaio_Native.h)
+
+target_link_libraries(artemis-native aio)
+
+set_target_properties(artemis-native PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ../../../bin)
+
+# It is weird but this is how you are supposed to validate between 32 and 64 bits architecture
+if (CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set_target_properties(artemis-native PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ../../../bin
+ LIBRARY_OUTPUT_NAME artemis-native-64)
+ message("-- Setting up library as artemis-native-64 based on current architecture")
+else()
+ set_target_properties(artemis-native PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY ../../../bin
+ LIBRARY_OUTPUT_NAME artemis-native-32)
+ message("-- Setting up library as artemis-native-32 based on current architecture")
+endif()