diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml index 6fc5a7310a..a528ddbb5c 100644 --- a/apache-maven/pom.xml +++ b/apache-maven/pom.xml @@ -128,6 +128,22 @@ under the License. + + org.apache.maven.plugins + maven-dependency-plugin + + jansi + META-INF/native/** + + + + unpack-jansi-native + + unpack-dependencies + + + + org.apache.maven.plugins maven-compiler-plugin @@ -215,6 +231,7 @@ under the License. clean-target-dir prepare-package + true ${distributionTargetDir} diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn index cfb39b0f9f..df62f68bd7 100755 --- a/apache-maven/src/bin/mvn +++ b/apache-maven/src/bin/mvn @@ -191,5 +191,4 @@ exec "$JAVACMD" \ -classpath "${CLASSWORLDS_JAR}" \ "-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \ "-Dmaven.home=${MAVEN_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - "-Dlibrary.jansi.path=${MAVEN_HOME}/lib/ext" \ ${CLASSWORLDS_LAUNCHER} "$@" diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd index c86662bb61..9d92279855 100644 --- a/apache-maven/src/bin/mvn.cmd +++ b/apache-maven/src/bin/mvn.cmd @@ -178,7 +178,6 @@ set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher "-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^ "-Dmaven.home=%MAVEN_HOME%" ^ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ - "-Dlibrary.jansi.path=%MAVEN_HOME%\lib\ext" ^ %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS% if ERRORLEVEL 1 goto error goto end diff --git a/apache-maven/src/lib/jansi-native/README.txt b/apache-maven/src/lib/jansi-native/README.txt new file mode 100644 index 0000000000..22857a64ef --- /dev/null +++ b/apache-maven/src/lib/jansi-native/README.txt @@ -0,0 +1,7 @@ +This directory contains Jansi native libraries, extracted from Jansi jar. + +You can add your own extensions for platforms not natively supported by +Jansi: the libraries follow HawtJNI directory and filename conventions. +See http://fusesource.github.io/hawtjni/documentation/api/org/fusesource/hawtjni/runtime/Library.html + +See https://github.com/fusesource/jansi-native for native lib source. diff --git a/apache-maven/src/main/assembly/component.xml b/apache-maven/src/main/assembly/component.xml index ca4dcb69a3..7b05af7c71 100644 --- a/apache-maven/src/main/assembly/component.xml +++ b/apache-maven/src/main/assembly/component.xml @@ -55,6 +55,14 @@ under the License. ** + + target/dependency/META-INF/native + lib/jansi-native + + ** + + 0755 + src/bin bin diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index b3367c177c..350fa61c5d 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -185,6 +185,7 @@ public class MavenCli { MavenCli cli = new MavenCli(); + prepareJansiNative(); MessageUtils.systemInstall(); int result = cli.doMain( new CliRequest( args, classWorld ) ); MessageUtils.systemUninstall(); @@ -192,6 +193,64 @@ public class MavenCli return result; } + /** + * temporary method while improvement reported to JAnsi+HawtJNI and integrated: + * library.jansi.path should point to lib/jansi-native and HawtJNI should be able to detect + * the platform instead of forcing the user having to point library.jansi.path to + * lib/jansi-native/[platform] + */ + private static void prepareJansiNative() + { + if ( System.getProperty( "library.jansi.path" ) == null ) + { + String mavenHome = System.getProperty( "maven.home" ); + + if ( mavenHome != null ) + { + File jansiNative = new File( mavenHome, "lib/jansi-native/" + hawtJNIgetPlatform() ); + System.setProperty( "library.jansi.path", jansiNative.getAbsolutePath() ); + } + } + } + + private static String hawtJNIgetOperatingSystem() + { + String name = System.getProperty( "os.name" ).toLowerCase().trim(); + if ( name.startsWith( "linux" ) ) + { + return "linux"; + } + if ( name.startsWith( "mac os x" ) ) + { + return "osx"; + } + if ( name.startsWith( "win" ) ) + { + return "windows"; + } + return name.replaceAll( "\\W+", "_" ); + + } + + private static String hawtJNIgetPlatform() + { + return hawtJNIgetOperatingSystem() + hawtJNIgetBitModel(); + } + + private static int hawtJNIgetBitModel() + { + String prop = System.getProperty( "sun.arch.data.model" ); + if ( prop == null ) + { + prop = System.getProperty( "com.ibm.vm.bitmode" ); + } + if ( prop != null ) + { + return Integer.parseInt( prop ); + } + return -1; // we don't know.. + } + // TODO need to externalize CliRequest public static int doMain( String[] args, ClassWorld classWorld ) {