fusesource / jansi

Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
http://fusesource.github.io/jansi/
Apache License 2.0
1.11k stars 140 forks source link

Support Mac-arm64 target #218

Closed electrum closed 2 years ago

electrum commented 3 years ago

It would be nice if Jansi worked on the M1 so that colors work in Maven.

mattsalt commented 3 years ago

Colours worked on maven 3.8.1 using Jansi 1.17.1 but not in maven 3.8.2 using Jansi 2.3.4.

Confirmed using the example snippet in the README. System.out.println( ansi().eraseScreen().fg(RED).a("Hello").fg(GREEN).a(" World").reset() );

1.17.1 image

2.3.4 image

Stopped working in 2.1.1

mattsalt commented 3 years ago

Looks like there was no native method in 2.0.1 either but the exception was caught and defaulted to RESET_ANSI_AT_CLOSE

electrum commented 3 years ago

I found that colors still work with -Dstyle.color=always.

mattsalt commented 3 years ago

That's handy. alias mvn="mvn -Dstyle.color=always it is then.

davsclaus commented 2 years ago

Anyone tracked down why colors stopped workin in 2.1.1?

I dont have colours either in mvn 3.8.2

davsclaus commented 2 years ago

$ uname -a Darwin davsclaus-mini.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 arm64

Its a apple m1 mac mini

davsclaus commented 2 years ago

@gnodet btw when you use maven 3.8.3, and mvnd 0.6.0 then you have this on aarch64 mac apple m1

mvnd --version
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:91)
Caused by: java.lang.RuntimeException: Unable to load jansi native library
    at org.fusesource.jansi.internal.JansiLoader.initialize(JansiLoader.java:62)
    at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:30)
    ... 1 more
Caused by: java.lang.Exception: No native library found for os.name=Mac, os.arch=aarch64, paths=[/opt/homebrew/Cellar/mvnd/0.6.0/libexec/mvn/lib/jansi-native/Mac/aarch64:/opt/homebrew/Cellar/mvnd/0.6.0/libexec/mvn/lib/jansi-native:/Users/davsclaus/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
    at org.fusesource.jansi.internal.JansiLoader.loadJansiNativeLibrary(JansiLoader.java:333)
    at org.fusesource.jansi.internal.JansiLoader.initialize(JansiLoader.java:60)
    ... 2 more

So if we can get jansi to support aarch64 and into a new release then mvnd could use that and get this working ;)

gnodet commented 2 years ago

Could you try the #222 PR and see if the library is valid ? Simply building jansi and replacing the binary in mvnd / mvn installation should do the trick... I can't really test it with my x64 Mac ;-)

davsclaus commented 2 years ago

@gnodet not sure if I should build it in another way, this is what I did, see the gist https://gist.github.com/davsclaus/28fb6898dbe23cf8971a43aa892cdbfe

And this is with your PR merged.

commit 5fe9293a9985da947787edd94acb63a87a826715 (HEAD -> gnodet-mac-arm64) Author: Guillaume Nodet gnodet@gmail.com Date: Tue Oct 5 11:54:15 2021 +0200

Support Mac-arm64 target, fixes #218
gnodet commented 2 years ago

@gnodet not sure if I should build it in another way, this is what I did, see the gist https://gist.github.com/davsclaus/28fb6898dbe23cf8971a43aa892cdbfe

And this is with your PR merged.

commit 5fe9293 (HEAD -> gnodet-mac-arm64) Author: Guillaume Nodet gnodet@gmail.com Date: Tue Oct 5 11:54:15 2021 +0200

Support Mac-arm64 target, fixes #218

@davsclaus , this looks like maven is shading the being-built version of jansi. Could you comment the exec-maven-plugin plugin from the pom so that you can actually build jansi ?

Then simply run the following command and give the output ?

java -jar target/jansi-2.3.5-SNAPSHOT.jar
davsclaus commented 2 years ago

Thanks, here is the output https://gist.github.com/davsclaus/be3c988a59ec1bd3042964458159adfb