[
https://issues.apache.org/jira/browse/MNG-6225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16001441#comment-16001441
]
Gili commented on MNG-6225:
---------------------------
Thanks for asking for a minimal testcase. As painful as it was to try to
produce, it helped me figure out the problem.
* In order to use native code, one has to point {{java.library.path}} to the
directory holding the native library.
* There are 3 ways to set this:
** Plugin-specific configuration (e.g. Surefire
{{<argLine>-Djava.library.path=X</argLine>}})
** Pass the system properties to the {{mvn}} command-line launcher: {{mvn
-Djava.library.path=X goals}}
** Set {{MAVEN_OPTS=-Djava.library.path=X}} prior to running {{mvn}}
command-line launcher.
I was initially configuring Surefire with {{<forkCount>0</forkCount>}} and
setting {{<argLine>}}. I assumed that adding {{<forkCount>0</forkCount>}} would
be enough to transition from a forked processed to a non-forked process, but I
was wrong. When the process is not forked, {{<argLine>}} gets ignored and the
system properties of the initial Maven process gets used instead. This seems
obvious in hindsight but was not obvious at the moment.
I then tried the other two options. It turns out that {{mvn -Dkey=value goals}}
is meant for non-JVM system properties (e.g. if the user application wants to
read a system property). This leaves us with one option: setting the
{{MAVEN_OPTS=-Djava.library.path=X}} environment variable. This worked.
As a result, I would like to request two changes:
1. Maven CLI should warn when it is passed a JVM system property since we know
these cannot be set this way.
2. Surefire should warn when {{<forkCount>0</forkCount>}} is mixed with
{{<argLine>}}
I will file a separate bug report against Surefire for the second point. Are
you able to convert this bug report for the first point?
> Application cannot output ANSI colors when run by Maven
> -------------------------------------------------------
>
> Key: MNG-6225
> URL: https://issues.apache.org/jira/browse/MNG-6225
> Project: Maven
> Issue Type: Bug
> Components: Command Line, core
> Affects Versions: 3.5.0
> Reporter: Gili
>
> I'm not sure which Maven component this bug report belongs to (please
> reassign if needed).
> This is a follow-up to https://issues.apache.org/jira/browse/SUREFIRE-1369
> To recap: someone (probably Maven core) is redirecting the native stdout
> handle when running plugins such as Surefire. This prevents applications from
> outputting ANSI colors under Windows 10 because:
> * Applications must explicitly enable ANSI support using JNI.
> * The JNI calls fail if the stdout handle has been redirected.
> If I run the exact same application outside of Maven, JNI no longer detects
> that stdout has been redirected and ANSI colors as expected.
> Any idea who is doing the redirection, and how to disable it?
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)