maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject maven git commit: [MNG-6115] prevent JAnsi from writing temp native files to lib/ext
Date Sat, 04 Mar 2017 23:39:34 GMT
Repository: maven
Updated Branches:
  refs/heads/MNG-6115-2 [created] c36cf425c


[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/c36cf425
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/c36cf425
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/c36cf425

Branch: refs/heads/MNG-6115-2
Commit: c36cf425cda7492b6be055cacdef0732e0062a36
Parents: 748551d
Author: Hervé Boutemy <hboutemy@apache.org>
Authored: Sun Mar 5 00:39:31 2017 +0100
Committer: Hervé Boutemy <hboutemy@apache.org>
Committed: Sun Mar 5 00:39:31 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    |  5 ++
 apache-maven/src/main/assembly/component.xml    |  8 +++
 .../java/org/apache/maven/cli/MavenCli.java     | 59 ++++++++++++++++++++
 6 files changed, 89 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/c36cf425/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/c36cf425/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/c36cf425/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/c36cf425/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..4c74f2c
--- /dev/null
+++ b/apache-maven/src/lib/jansi-native/README.txt
@@ -0,0 +1,5 @@
+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

http://git-wip-us.apache.org/repos/asf/maven/blob/c36cf425/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/c36cf425/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 8d38ab0..8a8ebdc 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
@@ -202,6 +202,7 @@ public class MavenCli
     {
         MavenCli cli = new MavenCli();
 
+        prepareJansiNative();
         MessageUtils.systemInstall();
         int result = cli.doMain( new CliRequest( args, classWorld ) );
         MessageUtils.systemUninstall();
@@ -209,6 +210,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 )
     {


Mime
View raw message