Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #80

Closed
TWiStErRob opened this issue Nov 8, 2022 · 3 comments · Fixed by #249
Closed

Windows support #80

TWiStErRob opened this issue Nov 8, 2022 · 3 comments · Fixed by #249

Comments

@TWiStErRob
Copy link
Contributor

I was playing around and I was having problems making it work out of the box, but I did it in the end. I'm opening an issue instead of a PR, because I'm not sure in what style would you apply these changes. The main fix that's absolutely necessary is patch 2 for jansi (see 4.).

Below is what I observed and learned:

  1. IntelliJ IDEA terminal view supports color and relocation of cursor
    (Gradle output is colored and workers are shown)

    • Command Prompt (cmd)
    • Windows Powershell
    • Ubuntu Bash (from WSL)
    • image
  2. Gradle :run task is JavaExec type and it messes with System.out in some way
    See Document how to enable color-coded output from bootRun spring-projects/spring-boot#24169 where they gave up supporting colors in Gradle, this seems to be because of Can't use System.console() with the Gradle Daemon gradle/gradle#1251, but this assumption is not conclusive as they're talking about console input there.

  3. :jar in samples doesn't produce a runnable jar file even though the application plugin is applied. (easy fix)

    Patch 1: make jar runnable

    Applied to each sample:

    jar {
    	manifest {
    		attributes(
    			'Main-Class': mainClassName,
    		)
    	}
    	from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }}
    	exclude('META-INF/versions/9/module-info.class')
    }
  4. jansi is not set up correctly in mosaic, because it detects tty, but is not rendering correctly

    Example unprocessed ansi output
    Tests: 10 total←[K
    Time:  0s      ←[K
    ←[F←[F←[30;43m RUNS ←[39;49m tests/←[1mlogin.kt←[22m                   ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1msignup.kt←[22m                  ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1mforgot-password.kt←[22m         ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1mreset-password.kt←[22m          ←[K
                                            ←[K
    Tests: ←[33m4 running←[39m, 10 total              ←[K
    Time:  0s                               ←[K
    ←[43m                ←[100m                        ←[0m←[K
    ←[F←[F←[F←[F←[F←[F←[F←[F←[30;43m RUNS ←[39;49m tests/←[1mlogin.kt←[22m                   ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1msignup.kt←[22m                  ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1mforgot-password.kt←[22m         ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1mreset-password.kt←[22m          ←[K
                                            ←[K
    Tests: ←[33m4 running←[39m, 10 total              ←[K
    Time:  0s                               ←[K
    ←[100m                                        ←[0m←[K
    ←[F←[F←[F←[F←[F←[F←[F←[F←[30;43m RUNS ←[39;49m tests/←[1mlogin.kt←[22m                   ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1msignup.kt←[22m                  ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1mforgot-password.kt←[22m         ←[K
    ←[30;43m RUNS ←[39;49m tests/←[1mreset-password.kt←[22m          ←[K
                                            ←[K
    
    Patch 2: set up jansi as documented
    diff --git a/mosaic-runtime/src/main/kotlin/com/jakewharton/mosaic/output.kt b/mosaic-runtime/src/main/kotlin/com/jakewharton/mosaic/output.kt
    --- a/mosaic-runtime/src/main/kotlin/com/jakewharton/mosaic/output.kt	(revision 95c0826ab30a226e363ee773904fb2e7b3bb6d01)
    +++ b/mosaic-runtime/src/main/kotlin/com/jakewharton/mosaic/output.kt	(date 1667899762778)
    @@ -36,6 +36,10 @@
     internal object AnsiOutput : Output {
        private var lastHeight = 0
     
    +	init {
    +		AnsiConsole.systemInstall()
    +	}
    +
        override fun display(canvas: TextCanvas) {
            val rendered = buildString {
                repeat(lastHeight) {
  5. At this point running gradlew -p samples :jest:jar and then java -jar samples\jest\build\libs\jest.jar works nicely (ignoring Unicode problems)

    • image
    • image
@JakeWharton
Copy link
Owner

Is this still an issue? I don't have a Windows machine to test.

1 & 2 don't seem relevant to our code. We don't do terminal detection and unconditionally emit ANSI control sequences today.

3 is not a goal. Use the installDist or distZip tasks to produce a runnable binary (either as an exploded folder or a .zip)

If 4 is still an issue, you can send a PR to platform.kt and run install before assigning the out private property.

@TWiStErRob

This comment was marked as outdated.

@TWiStErRob
Copy link
Contributor Author

TWiStErRob commented Nov 13, 2023

  1. was just context to see where I'm coming from
  2. and what I tried.
  3. Ugh, RTFM, :slap:, thanks!
  4. Yes, still an issue → Initialize AnsiConsole before usage #249
  5. The right command is indeed gradlew :samples:jest:installDist && samples\jest\build\install\jest\bin\jest.bat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants