diff --git a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java index b0b7244989..d691dfb5a1 100644 --- a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java +++ b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java @@ -24,8 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; -import java.util.Locale; -import java.util.regex.Pattern; /** * Helper class to load JNI resources. @@ -35,7 +33,6 @@ public final class NativeLibraryLoader { private static final InternalLogger logger = InternalLoggerFactory.getInstance(NativeLibraryLoader.class); - private static final Pattern REPLACE = Pattern.compile("\\W+"); private static final File WORKDIR; static { @@ -67,7 +64,7 @@ public final class NativeLibraryLoader { */ public static void load(String name, ClassLoader loader) { String libname = System.mapLibraryName(name); - String path = "META-INF/native/" + osIdentifier() + PlatformDependent.bitMode() + '/' + libname; + String path = "META-INF/native/" + libname; URL url = loader.getResource(path); if (url == null) { @@ -128,21 +125,6 @@ public final class NativeLibraryLoader { } } - private static String osIdentifier() { - String name = SystemPropertyUtil.get("os.name", "unknown").toLowerCase(Locale.US).trim(); - if (name.startsWith("win")) { - return "windows"; - } - if (name.startsWith("mac os x")) { - return "osx"; - } - if (name.startsWith("linux")) { - return "linux"; - } - - return REPLACE.matcher(name).replaceAll("_"); - } - private NativeLibraryLoader() { // Utility } diff --git a/pom.xml b/pom.xml index 8423c1df47..5383e28a71 100644 --- a/pom.xml +++ b/pom.xml @@ -362,6 +362,14 @@ + + + kr.motd.maven + os-maven-plugin + 1.1.1 + + + maven-enforcer-plugin @@ -805,6 +813,11 @@ exec-maven-plugin 1.2.1 + + org.fusesource.hawtjni + maven-hawtjni-plugin + 1.10 + diff --git a/transport-native-epoll/pom.xml b/transport-native-epoll/pom.xml index b9aa83d462..cb6699ff7c 100644 --- a/transport-native-epoll/pom.xml +++ b/transport-native-epoll/pom.xml @@ -60,39 +60,16 @@ org.fusesource.hawtjni maven-hawtjni-plugin - 1.10 - build-linux64 + build-native-lib - ${project.artifactId} - ${project.build.directory}/linux64 - ${nativeSourceDirectory} - ${libDirectory} - - --with-arch=x86_64 - - linux64 - true - true - - - generate - build - - compile - - - build-linux32 - - ${project.build.directory}/linux32 - ${nativeSourceDirectory} - ${libDirectory} - ${project.artifactId} - - --with-arch=i386 - - linux32 + ${project.basedir}/src/main/c + ${project.build.outputDirectory} + + . true true @@ -104,10 +81,15 @@ + + + + maven-jar-plugin + + ${os.detected.classifier} + + - - ${basedir}/src/main/c - ${basedir}/target/classes/ - + diff --git a/transport-native-epoll/src/main/native-package/m4/custom.m4 b/transport-native-epoll/src/main/native-package/m4/custom.m4 deleted file mode 100644 index c3ffe7d167..0000000000 --- a/transport-native-epoll/src/main/native-package/m4/custom.m4 +++ /dev/null @@ -1,47 +0,0 @@ -dnl --------------------------------------------------------------------------- -dnl Copyright 2014 The Netty Project -dnl -dnl Licensed under the Apache License, Version 2.0 (the "License"); -dnl you may not use this file except in compliance with the License. -dnl You may obtain a copy of the License at -dnl -dnl http://www.apache.org/licenses/LICENSE-2.0 -dnl -dnl Unless required by applicable law or agreed to in writing, software -dnl distributed under the License is distributed on an "AS IS" BASIS, -dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -dnl See the License for the specific language governing permissions and -dnl limitations under the License. -dnl --------------------------------------------------------------------------- - -AC_DEFUN([CUSTOM_M4_SETUP], -[ - AC_MSG_CHECKING(which arch to build for) - AC_ARG_WITH([arch], - [AS_HELP_STRING([--with-arch@<:@=ARCH@:>@], - [Build for the specified architecture. Pick from: i386, x86_64.])], - [ - AS_IF(test -n "$withval", [ - ARCH="$withval" - AC_MSG_RESULT([yes, archs: $ARCH]) - ]) - ],[ - ARCH="" - AC_MSG_RESULT([no]) - ]) - AS_IF(test "$ARCH" = "i386", [ - FLAGS="-m32" - ], test "ARCH" = "x86_64", [ - FLAGS="-m64" - ], [ - FLAGS="" - ]) - AS_IF(test -n "$FLAGS", [ - CFLAGS="$FLAGS $CFLAGS" - CXXFLAGS="$FLAGS $CXXFLAGS" - LDFLAGS="$FLAGS $ARCH $LDFLAGS" - AC_SUBST(CFLAGS) - AC_SUBST(CXXFLAGS) - AC_SUBST(LDFLAGS) - ]) -]) \ No newline at end of file