Tuesday, November 27, 2012

Akka in Eclipse on Mac OS

These are my rough notes for getting Akka HEAD going in Eclipse with the Scala plugin. I used a nightly build of the plugin to get support for a recent version of Scala.

  1. Fork the Akka repository.
  2. Make a local clone of your fork.
    git clone git@github.com:richdougherty/akka.git akka
  3. Build it and run tests.
    $ sbt test
  4. Create an ~/.sbt/plugins/plugins.sbt file to teach SBT about the sbteclipse plugin.
    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
  5. Generate Eclipse project metadata.
    $ sbt eclipse
  6. Download Eclipse Indigo SR2 and install it somewhere. Do not run it yet.
  7. Find the Eclipse application and view its contents by right-clicking and choosing Show package contents.
  8. Update Contents/MacOS/eclipse.ini according to these instructions. OK, I used a bit more memory. My changes were:
    $ diff -u Eclipse.app/Contents/MacOS/eclipse.ini Eclipse\ retinafied.app/Contents/MacOS/eclipse.ini 
    --- Eclipse.app/Contents/MacOS/eclipse.ini 2012-11-26 13:48:13.000000000 +0100
    +++ Eclipse retinafied.app/Contents/MacOS/eclipse.ini 2012-11-26 14:00:45.000000000 +0100
    @@ -16,9 +16,11 @@
     -Dosgi.requiredJavaVersion=1.5
     -XstartOnFirstThread
     -Dorg.eclipse.swt.internal.carbon.smallFonts
    --XX:MaxPermSize=256m
    --Xms40m
    --Xmx384m
    +-XX:PermSize=256M
    +-XX:MaxPermSize=512M
    +-Xms512m
    +-Xmx1280m
     -Xdock:icon=../Resources/Eclipse.icns
     -XstartOnFirstThread
     -Dorg.eclipse.swt.internal.carbon.smallFonts
    +-XX:+UseParallelGC
    
  9. I have a high-res (Retina) screen on my Mac so I enabled high-resolution fonts for the Eclipse application according to these instructions. Update Contents/MacOS/eclipse.ini according to these instructions. If you've already started the application then your changes might not be picked up because of OS caching. Read the linked instructions for a workaround. My changes were:
    $ diff -u Eclipse.app/Contents/Info.plist Eclipse\ retinafied.app/Contents/Info.plist 
    --- Eclipse.app/Contents/Info.plist 2012-11-26 13:34:45.000000000 +0100
    +++ Eclipse retinafied.app/Contents/Info.plist 2012-11-27 11:40:36.000000000 +0100
    @@ -69,9 +69,6 @@
         -->
       </array>
     
    - <key>NSHighResolutionCapable</key>
    - <true/>
    -
     </dict>
     
     </plist>
    
  10. Open Eclipse.
  11. Tell Eclipse how to get the 2.10.x nightly build of the Scala plugin. Go to Help and choose Install New Software…. The update site is located at http://download.scala-ide.org/nightly-update-master-trunk. There are also milestone builds available.
  12. Go to General and Workspace and set the Text file encoding to UTF-8. Otherwise you'll get funny errors when Scala tries to compile the ⇒ characters in Akka source code.
  13. Use Import Existing Projects into Workspace… to pull in the Akka source code.
  14. Done!

Update: Explained how to add Scala plugin. Oops!

2 comments:

  1. It's also worth adding a VM setting, as explained here.

    I'm using
    -vm
    /Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/bin/java

    ReplyDelete
  2. My latest VM args look like this:

    -server
    -Dosgi.requiredJavaVersion=1.5
    -XstartOnFirstThread
    -Dorg.eclipse.swt.internal.carbon.smallFonts
    -XX:MaxPermSize=256m
    -Xms512m
    -Xmx2048m
    -Xss1M
    -XX:+UseConcMarkSweepGC

    ReplyDelete