You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/03/12 16:32:08 UTC
[16/17] maven git commit: [MNG-6115] prevent JAnsi from writing temp
native files to lib/ext
[MNG-6115] prevent JAnsi from writing temp native files to lib/ext
Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/181b0215
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/181b0215
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/181b0215
Branch: refs/heads/MNG-6169
Commit: 181b0215aa1199e152db9d2c08b1a01436547805
Parents: 809ba34
Author: Herv� Boutemy <hb...@apache.org>
Authored: Sun Mar 5 00:39:31 2017 +0100
Committer: Herv� Boutemy <hb...@apache.org>
Committed: Sun Mar 12 12:12:16 2017 +0100
----------------------------------------------------------------------
apache-maven/pom.xml | 17 ++++++
apache-maven/src/bin/mvn | 1 -
apache-maven/src/bin/mvn.cmd | 1 -
apache-maven/src/lib/jansi-native/README.txt | 7 +++
apache-maven/src/main/assembly/component.xml | 8 +++
.../java/org/apache/maven/cli/MavenCli.java | 59 ++++++++++++++++++++
6 files changed, 91 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven/blob/181b0215/apache-maven/pom.xml
----------------------------------------------------------------------
diff --git a/apache-maven/pom.xml b/apache-maven/pom.xml
index 6fc5a73..a528ddb 100644
--- a/apache-maven/pom.xml
+++ b/apache-maven/pom.xml
@@ -130,6 +130,22 @@ under the License.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <includeArtifactIds>jansi</includeArtifactIds>
+ <includes>META-INF/native/**</includes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>unpack-jansi-native</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
@@ -215,6 +231,7 @@ under the License.
<id>clean-target-dir</id>
<phase>prepare-package</phase>
<configuration>
+ <excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${distributionTargetDir}</directory>
http://git-wip-us.apache.org/repos/asf/maven/blob/181b0215/apache-maven/src/bin/mvn
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/mvn b/apache-maven/src/bin/mvn
index cfb39b0..df62f68 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} "$@"
http://git-wip-us.apache.org/repos/asf/maven/blob/181b0215/apache-maven/src/bin/mvn.cmd
----------------------------------------------------------------------
diff --git a/apache-maven/src/bin/mvn.cmd b/apache-maven/src/bin/mvn.cmd
index c86662b..9d92279 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
http://git-wip-us.apache.org/repos/asf/maven/blob/181b0215/apache-maven/src/lib/jansi-native/README.txt
----------------------------------------------------------------------
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 0000000..22857a6
--- /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.
http://git-wip-us.apache.org/repos/asf/maven/blob/181b0215/apache-maven/src/main/assembly/component.xml
----------------------------------------------------------------------
diff --git a/apache-maven/src/main/assembly/component.xml b/apache-maven/src/main/assembly/component.xml
index ca4dcb6..7b05af7 100644
--- a/apache-maven/src/main/assembly/component.xml
+++ b/apache-maven/src/main/assembly/component.xml
@@ -56,6 +56,14 @@ under the License.
</includes>
</fileSet>
<fileSet>
+ <directory>target/dependency/META-INF/native</directory>
+ <outputDirectory>lib/jansi-native</outputDirectory>
+ <includes>
+ <include>**</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
<directory>src/bin</directory>
<outputDirectory>bin</outputDirectory>
<includes>
http://git-wip-us.apache.org/repos/asf/maven/blob/181b0215/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
----------------------------------------------------------------------
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 b3367c1..350fa61 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 )
{