[MNG-6186] use enhanced HawtJNI library loading (remove previous hack)

This commit is contained in:
Hervé Boutemy 2017-05-06 18:28:04 +02:00
parent 2a79d1e71e
commit 6182a2083f
3 changed files with 4 additions and 60 deletions

View File

@ -193,5 +193,7 @@ exec "$JAVACMD" \
$MAVEN_DEBUG_OPTS \
-classpath "${CLASSWORLDS_JAR}" \
"-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \
"-Dmaven.home=${MAVEN_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
"-Dmaven.home=${MAVEN_HOME}" \
"-Dlibrary.jansi.path=${MAVEN_HOME}/jansi-native" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${CLASSWORLDS_LAUNCHER} "$@"

View File

@ -181,6 +181,7 @@ set CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-classpath %CLASSWORLDS_JAR% ^
"-Dclassworlds.conf=%MAVEN_HOME%\bin\m2.conf" ^
"-Dmaven.home=%MAVEN_HOME%" ^
"-Dlibrary.jansi.path=%MAVEN_HOME%\jansi-native" ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error

View File

@ -188,7 +188,6 @@ public class MavenCli
{
MavenCli cli = new MavenCli();
prepareJansiNative();
MessageUtils.systemInstall();
int result = cli.doMain( new CliRequest( args, classWorld ) );
MessageUtils.systemUninstall();
@ -196,64 +195,6 @@ 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 )
{