mihnita / ansi-econsole

Eclipse plugin that understands ANSI escape sequences to color the Eclipse console output.
http://www.mihai-nita.net/java/
Other
90 stars 25 forks source link

Coloring doesn't work in 2020-06 #53

Closed impl1874 closed 4 years ago

impl1874 commented 4 years ago

hi. i found the same problem Coloring doesn't work in 2020-03 in: Ansi Console 1.4.2.202002090224 net.mihai-nita.ansicon.feature.group Mihai Nita

but print code work normal.color normal: System.out.println("Hello \u001b[31m red world!"); System.out.println("Hello \u001b[31m red world!");

test env and test method: mvn clean install -X Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /Users/yuzhen/develop_software/maven/apache-maven-3.6.3 Java version: 1.8.0_241, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "mac os x", version: "10.15.6", arch: "x86_64", family: "mac"

my system: mac os 10.15.6 (19G73)

myeclipse version: Eclipse IDE for Java Developers (includes Incubating components) Version: 2020-06 (4.16.0) Build id: 20200615-1200

1、new eclipse workspace. no help 2、reinstall plugin. no help 3、check enable/disable.check Preferences. no help

Please help me.Thanks.

impl1874 commented 4 years ago

1、OS and OS versions? 2、Can you see the enable / disable icon at the top-right of the console? 3、Can you see "Ansi Console" in Preferences? Does that panel seem to work? 4、If you go to About Eclipse and click "Installation details" can you see it in the "Installed Software" tab? What version?

  1. mac os 10.15.6 (19G73)
  2. yes
  3. yes
  4. the list: a.Subversive b.Ali-CodeAnalysis c.WindowBuilder d.googlejavaformatter

eclipse configuration:no Features *** Date: 2020年8月5日星期三 中国标准时间 下午3:47:57

*** Platform Details:

*** System properties: applicationXMI=org.eclipse.ui.workbench/LegacyIDE.e4xmi awt.toolkit=sun.lwawt.macosx.LWCToolkit ds.delayed.keepInstances=true ds.delayed.keepInstances.default=true eclipse.application=org.eclipse.ui.ide.workbench eclipse.buildId=4.16.0.I20200604-0540 eclipse.commands=-os macosx -ws cocoa -arch x86_64 -showsplash -launcher /Applications/Eclipse.app/Contents/MacOS/eclipse -name Eclipse --launcher.library /Applications/Eclipse.app/Contents/MacOS//../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.1200.v20200508-1552/eclipse_1902.so -startup /Applications/Eclipse.app/Contents/MacOS//../Eclipse/plugins/org.eclipse.equinox.launcher_1.5.700.v20200207-2156.jar --launcher.appendVmargs -product org.eclipse.epp.package.java.product -keyring /Users/yuzhen/.eclipse_keyring -vm /Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home/bin/../lib/server/libjvm.dylib eclipse.home.location=file:/Applications/Eclipse.app/Contents/Eclipse/ eclipse.launcher=/Applications/Eclipse.app/Contents/MacOS/eclipse eclipse.launcher.name=Eclipse eclipse.p2.data.area=@config.dir/../p2/ eclipse.p2.profile=epp.package.java eclipse.product=org.eclipse.epp.package.java.product eclipse.startTime=1596613181796 eclipse.stateSaveDelayInterval=30000 eclipse.vm=/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home/bin/../lib/server/libjvm.dylib eclipse.vmargs=-Dosgi.requiredJavaVersion=1.8 -Dosgi.instance.area.default=@user.home/eclipse-workspace -XX:+UseG1GC -XX:+UseStringDeduplication --add-modules=ALL-SYSTEM -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Dosgi.requiredJavaVersion=1.8 -Dosgi.dataAreaRequiresExplicitInit=true -Xms256m -Xmx2048m --add-modules=ALL-SYSTEM -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -javaagent:/Applications/Eclipse.app/Contents/Eclipse/lombok.jar -Djava.class.path=/Applications/Eclipse.app/Contents/MacOS//../Eclipse/plugins/org.eclipse.equinox.launcher_1.5.700.v20200207-2156.jar equinox.init.uuid=true file.encoding=UTF-8 file.separator=/ gopherProxySet=false gosh.args=--nointeractive guice.disable.misplaced.annotation.check=true java.awt.graphicsenv=sun.awt.CGraphicsEnvironment java.awt.printerjob=sun.lwawt.macosx.CPrinterJob java.class.path=/Applications/Eclipse.app/Contents/MacOS//../Eclipse/plugins/org.eclipse.equinox.launcher_1.5.700.v20200207-2156.jar java.class.version=55.0 java.home=/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home java.io.tmpdir=/var/folders/my/d2rd_mkx20b74spj0vbw8mmm0000gn/T/ java.library.path=/Users/yuzhen/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. java.runtime.name=Java(TM) SE Runtime Environment java.runtime.version=11.0.8+10-LTS java.specification.name=Java Platform API Specification java.specification.vendor=Oracle Corporation java.specification.version=11 java.vendor=Oracle Corporation java.vendor.url=https://openjdk.java.net/ java.vendor.url.bug=https://bugreport.java.com/bugreport/ java.vendor.version=18.9 java.version=11.0.8 java.version.date=2020-07-14 java.vm.compressedOopsMode=32-bit java.vm.info=mixed mode java.vm.name=Java HotSpot(TM) 64-Bit Server VM java.vm.specification.name=Java Virtual Machine Specification java.vm.specification.vendor=Oracle Corporation java.vm.specification.version=11 java.vm.vendor=Oracle Corporation java.vm.version=11.0.8+10-LTS jdk.debug=release line.separator= maven.defaultProjectBuilder.disableGlobalModelCache=true org.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog org.eclipse.debug.ui.breakpoints.toggleFactoriesUsed=false org.eclipse.equinox.launcher.splash.location=/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.platform_4.16.0.v20200604-0540/splash.bmp org.eclipse.equinox.simpleconfigurator.configUrl=file:org.eclipse.equinox.simpleconfigurator/bundles.info org.eclipse.m2e.log.dir=/Users/yuzhen/eclipse-workspace/.metadata/.plugins/org.eclipse.m2e.logback.configuration org.eclipse.swt.internal.carbon.smallFonts= org.eclipse.swt.internal.deviceZoom=200 org.osgi.framework.executionenvironment=OSGi/Minimum-1.0, OSGi/Minimum-1.1, OSGi/Minimum-1.2, JavaSE/compact1-1.8, JavaSE/compact2-1.8, JavaSE/compact3-1.8, JRE-1.1, J2SE-1.2, J2SE-1.3, J2SE-1.4, J2SE-1.5, JavaSE-1.6, JavaSE-1.7, JavaSE-1.8, JavaSE-9, JavaSE-10, JavaSE-11 org.osgi.framework.language=zh org.osgi.framework.os.name=MacOSX org.osgi.framework.os.version=10.15.6 org.osgi.framework.processor=x86-64 org.osgi.framework.storage=/Applications/Eclipse.app/Contents/Eclipse/configuration org.osgi.framework.system.capabilities=osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0, 1.1, 1.2", osgi.ee; osgi.ee="JRE"; version:List="1.0, 1.1", osgi.ee; osgi.ee="JavaSE"; version:List="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9.0, 10.0, 11.0",osgi.ee; osgi.ee="JavaSE/compact1"; version:List="1.8, 9.0, 10.0, 11.0",osgi.ee; osgi.ee="JavaSE/compact2"; version:List="1.8, 9.0, 10.0, 11.0",osgi.ee; osgi.ee="JavaSE/compact3"; version:List="1.8, 9.0, 10.0, 11.0" org.osgi.framework.system.packages=com.sun.jarsigner, com.sun.java.accessibility.util, com.sun.javadoc, com.sun.jdi, com.sun.jdi.connect, com.sun.jdi.connect.spi, com.sun.jdi.event, com.sun.jdi.request, com.sun.jndi.ldap.spi, com.sun.management, com.sun.net.httpserver, com.sun.net.httpserver.spi, com.sun.nio.file, com.sun.nio.sctp, com.sun.security.auth, com.sun.security.auth.callback, com.sun.security.auth.login, com.sun.security.auth.module, com.sun.security.jgss, com.sun.source.doctree, com.sun.source.tree, com.sun.source.util, com.sun.tools.attach, com.sun.tools.attach.spi, com.sun.tools.javac, com.sun.tools.javadoc, com.sun.tools.jconsole, java.applet, java.awt, java.awt.color, java.awt.datatransfer, java.awt.desktop, java.awt.dnd, java.awt.event, java.awt.font, java.awt.geom, java.awt.im, java.awt.im.spi, java.awt.image, java.awt.image.renderable, java.awt.print, java.beans, java.beans.beancontext, java.io, java.lang, java.lang.annotation, java.lang.instrument, java.lang.invoke, java.lang.management, java.lang.module, java.lang.ref, java.lang.reflect, java.math, java.net, java.net.http, java.net.spi, java.nio, java.nio.channels, java.nio.channels.spi, java.nio.charset, java.nio.charset.spi, java.nio.file, java.nio.file.attribute, java.nio.file.spi, java.rmi, java.rmi.activation, java.rmi.dgc, java.rmi.registry, java.rmi.server, java.security, java.security.acl, java.security.cert, java.security.interfaces, java.security.spec, java.sql, java.text, java.text.spi, java.time, java.time.chrono, java.time.format, java.time.temporal, java.time.zone, java.util, java.util.concurrent, java.util.concurrent.atomic, java.util.concurrent.locks, java.util.function, java.util.jar, java.util.logging, java.util.prefs, java.util.regex, java.util.spi, java.util.stream, java.util.zip, javax.accessibility, javax.annotation.processing, javax.crypto, javax.crypto.interfaces, javax.crypto.spec, javax.imageio, javax.imageio.event, javax.imageio.metadata, javax.imageio.plugins.bmp, javax.imageio.plugins.jpeg, javax.imageio.plugins.tiff, javax.imageio.spi, javax.imageio.stream, javax.lang.model, javax.lang.model.element, javax.lang.model.type, javax.lang.model.util, javax.management, javax.management.loading, javax.management.modelmbean, javax.management.monitor, javax.management.openmbean, javax.management.relation, javax.management.remote, javax.management.remote.rmi, javax.management.timer, javax.naming, javax.naming.directory, javax.naming.event, javax.naming.ldap, javax.naming.spi, javax.net, javax.net.ssl, javax.print, javax.print.attribute, javax.print.attribute.standard, javax.print.event, javax.rmi.ssl, javax.script, javax.security.auth, javax.security.auth.callback, javax.security.auth.kerberos, javax.security.auth.login, javax.security.auth.spi, javax.security.auth.x500, javax.security.cert, javax.security.sasl, javax.smartcardio, javax.sound.midi, javax.sound.midi.spi, javax.sound.sampled, javax.sound.sampled.spi, javax.sql, javax.sql.rowset, javax.sql.rowset.serial, javax.sql.rowset.spi, javax.swing, javax.swing.border, javax.swing.colorchooser, javax.swing.event, javax.swing.filechooser, javax.swing.plaf, javax.swing.plaf.basic, javax.swing.plaf.metal, javax.swing.plaf.multi, javax.swing.plaf.nimbus, javax.swing.plaf.synth, javax.swing.table, javax.swing.text, javax.swing.text.html, javax.swing.text.html.parser, javax.swing.text.rtf, javax.swing.tree, javax.swing.undo, javax.tools, javax.transaction.xa, javax.xml, javax.xml.catalog, javax.xml.crypto, javax.xml.crypto.dom, javax.xml.crypto.dsig, javax.xml.crypto.dsig.dom, javax.xml.crypto.dsig.keyinfo, javax.xml.crypto.dsig.spec, javax.xml.datatype, javax.xml.namespace, javax.xml.parsers, javax.xml.stream, javax.xml.stream.events, javax.xml.stream.util, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.sax, javax.xml.transform.stax, javax.xml.transform.stream, javax.xml.validation, javax.xml.xpath, jdk.dynalink, jdk.dynalink.beans, jdk.dynalink.linker, jdk.dynalink.linker.support, jdk.dynalink.support, jdk.javadoc.doclet, jdk.jfr, jdk.jfr.consumer, jdk.jshell, jdk.jshell.execution, jdk.jshell.spi, jdk.jshell.tool, jdk.management.jfr, jdk.nashorn.api.scripting, jdk.nashorn.api.tree, jdk.net, jdk.nio, jdk.security.jarsigner, jdk.swing.interop, netscape.javascript, org.ietf.jgss, org.w3c.dom, org.w3c.dom.bootstrap, org.w3c.dom.css, org.w3c.dom.events, org.w3c.dom.html, org.w3c.dom.ls, org.w3c.dom.ranges, org.w3c.dom.stylesheets, org.w3c.dom.traversal, org.w3c.dom.views, org.w3c.dom.xpath, org.xml.sax, org.xml.sax.ext, org.xml.sax.helpers, sun.misc, sun.reflect org.osgi.framework.uuid=fa342a48-8c71-49e4-ae9b-a59f16f68f7c org.osgi.framework.vendor=Eclipse org.osgi.framework.version=1.9.0 org.osgi.supports.framework.extension=true org.osgi.supports.framework.fragment=true org.osgi.supports.framework.requirebundle=true os.arch=x86_64 os.name=Mac OS X os.version=10.15.6 osgi.arch=x86_64 osgi.bundles=reference:file:org.eclipse.osgi.compatibility.state_1.1.800.v20200511-1223.jar,reference:file:org.eclipse.equinox.simpleconfigurator_1.3.500.v20200211-1505.jar@1:start osgi.bundles.defaultStartLevel=4 osgi.compatibility.bootdelegation=true osgi.compatibility.bootdelegation.default=true osgi.configuration.area=file:/Applications/Eclipse.app/Contents/Eclipse/configuration/ osgi.dataAreaRequiresExplicitInit=true osgi.framework=file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.osgi_3.15.300.v20200520-1959.jar osgi.framework.extensions=reference:file:org.eclipse.osgi.compatibility.state_1.1.800.v20200511-1223.jar osgi.framework.shape=jar osgi.framework.useSystemProperties=true osgi.frameworkClassPath=., file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.osgi.compatibility.state_1.1.800.v20200511-1223.jar osgi.install.area=file:/Applications/Eclipse.app/Contents/Eclipse/ osgi.instance.area=file:/Users/yuzhen/eclipse-workspace/ osgi.instance.area.default=file:/Users/yuzhen/eclipse-workspace/ osgi.logfile=/Users/yuzhen/eclipse-workspace/.metadata/.log osgi.nl=zhCN#Hans osgi.os=macosx osgi.requiredJavaVersion=1.8 osgi.splashLocation=/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.platform_4.16.0.v20200604-0540/splash.bmp osgi.splashPath=platform:/base/plugins/org.eclipse.platform osgi.syspath=/Applications/Eclipse.app/Contents/Eclipse/plugins osgi.tracefile=/Users/yuzhen/eclipse-workspace/.metadata/trace.log osgi.ws=cocoa path.separator=: sun.arch.data.model=64 sun.boot.library.path=/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home/lib sun.cpu.endian=little sun.cpu.isalist= sun.io.unicode.encoding=UnicodeBig sun.jnu.encoding=UTF-8 sun.management.compiler=HotSpot 64-Bit Tiered Compilers sun.os.patch.level=unknown user.country=CN user.dir=/Applications/Eclipse.app/Contents/MacOS user.home=/Users/yuzhen user.language=zh user.name=yuzhen user.script=Hans user.timezone=Asia/Shanghai

*** System environment variables: APP_ICON_83784=../Resources/Eclipse.icns HOME=/Users/yuzhen JAVA_STARTED_ON_FIRST_THREAD_83784=1 LOGNAME=yuzhen PATH=/usr/bin:/bin:/usr/sbin:/sbin SHELL=/bin/zsh SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.eI5g9xEzje/Listeners TMPDIR=/var/folders/my/d2rd_mkx20b74spj0vbw8mmm0000gn/T/ USER=yuzhen XPC_FLAGS=0x0 XPC_SERVICE_NAME=org.eclipse.platform.ide.12044 __CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34

mihnita commented 4 years ago

Thank you very much for all the details. I am still a bit puzzled though...

So this works: System.out.println("Hello \u001b[31m red world!"); But this does not: mvn clean install -X ?

How do you run mvn clean install -X from inside Eclipse?


Anyway...

If the direct print works, and something like mvn (or any other external tool) does not, then the most likely problem is that the tool detects that the output is not a terminal and disables colors.

A lot of tools do that so that escape sequences don't end up in a file (if you do mvn install > somefile.log then you will see the same thing, the file does not contain any ansi escapes)

I don't know of any way to make the Eclipse console report that it is a tty. So the only way is to force the tool to use colors even for for non-terminal output. How to do that is tool dependent.

You can try this by running (in command line, not Eclipse):

mvn clean install > file.log
cat file.log

The log file does not contain colors.

Then try:

MAVEN_OPTS="-Djansi.passthrough=true"
mvn clean install > file.log
cat file.log

You should now see the maven colors.

I am still trying to figure out how to force that in Eclipse.

And would still help if you tell me how are you running mvn clean install -X from Eclipse. Did you create a "Maven build" Run Configuration?

impl1874 commented 4 years ago

Did you create a "Maven build" Run Configuration? Yes. like this: create a "Maven build" Run Configuration? edit Goals "clean install -X" OR "clean install"

mihnita commented 4 years ago

Did some digging (including reading through the sources for maven, jansi, and some of the maven Eclipse plugins :-)

It is not a problem with the plugin, it is the fact that the Eclipse does not report that it is a terminal (tty). Because of that both maven and jansi don't output any color information.

And on top of that the "embedded" maven that comes with Eclipse uses the slf4j SimpleLogger, which does not even know about color at all, tty or not.

Here is a workaround, including some explanations at the end: https://mihai-nita.net/2020/08/23/force-maven-colors-in-eclipse-console/

impl1874 commented 4 years ago

Thanks. work well.

https://mihai-nita.net/2020/08/23/force-maven-colors-in-eclipse-console/ To force Maven to output color no matter the console type we need to set style.color=always. To force Jansi to output color we need to set -Djansi.passthrough=true.