Install groovy console on Mac and make it runnable from dock

0

How can I install and run Groovy console/IDE from the dock on Mac Sierra?

wick

Posted 2018-03-02T20:46:31.363

Reputation: 141

Try asking on the apple forum here: https://apple.stackexchange.com/

– HackSlash – 2018-03-02T20:55:35.120

1Does that 'best solution' work for you? If so you should post it as an answer, and not as part of the question :) – bertieb – 2018-03-03T11:16:27.780

@bertieb answer converted to community wiki – I say Reinstate Monica – 2018-03-17T16:00:02.500

Can I have a link to that wiki @ – wick – 2018-03-17T16:05:56.937

Answers

0

  1. Follow these instructions http://sdkman.io/install.html and make sure you restart your terminal session after each step;

  2. Say $ sdk install groovy to install groovy (I assume you have jdk already installed);

  3. Start your Groovy Console in terminal

    $ ~/.sdkman/candidates/groovy/current/bin/groovyConsole
    

    It runs as a separate process;

  4. Say $ ps aux |grep groovy - you will find out that the console is run as

    /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java -Xdock:name=GroovyConsole -Xdock:icon=/Users/yourname/.sdkman/candidates/groovy/current/lib/groovy.icns -classpath /Users/yourname/.sdkman/candidates/groovy/current/lib/groovy-2.4.14.jar -Dscript.name=/Users/yourname/.sdkman/candidates/groovy/current/bin/groovyConsole -Dprogram.name=groovyConsole -Dgroovy.starter.conf=/Users/yourname/.sdkman/candidates/groovy/current/conf/groovy-starter.conf -Dgroovy.home=/Users/yourname/.sdkman/candidates/groovy/current -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/lib/tools.jar org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.Console --conf /Users/yourname/.sdkman/candidates/groovy/current/conf/groovy-starter.conf --classpath .

    I will refer that mess as jvm-verylongline

  5. Exit the console and start automator.app, choose Application and double-click Run Shell Script action;

  6. Save it as groovyConsole.app to your home folder and exit automator;

  7. Edit ~/groovyConsole.app/Contents/Info.plist and change 3 lines:

    <key>CFBundleExecutable</key>
    <string>fuckmac</string>
    <key>CFBundleIconFile</key>
    <string>groovy</string>
    <key>CFBundleIdentifier</key>
    <string>com.apple.groovyConsole</string>
    
  8. Create file ~/groovyConsole.app/Contents/MacOS/fuckmac and make it read:

    #!/bin/bash
    exec -c jvm-verylongline
    

    Replacing jvm-verylongline as per above, obviously;

  9. Say $ chmod +x ~/groovyConsole.app/Contents/MacOS/fuckmac

  10. As the icon is conveniently named in the jvm-verylongline, do

    $ cp /Users/yourname/.sdkman/candidates/groovy/current/lib/groovy.icns ~/groovyConsole.app/Contents/Resources/
    
  11. Now you should be able to run the app by double-clicking it in Finder, but probably still with the wrong icon due to caching;

  12. Drag-and-drop the app from your home folder to Applications in Finder - this is when the icon malarkey gets fixed;

  13. Now you can also drag-and-drop to dock the app.


Note: This solution was originally posted by the OP as an edit to the question

I say Reinstate Monica

Posted 2018-03-02T20:46:31.363

Reputation: 21 477