2012年3月20日火曜日

Scala, Android, Eclipse, Ubuntu 11.10 開発環境の構築

環境

  • Ubuntu 11.10 32bit

インストールしたものは次の通り。

  • Android SDK r16
  • sun-java6
  • sbt 0.11.2
  • conscript
  • giter8
  • sbt-android-plugin(自動)
  • Eclipse Indigo 3.7.2
    • Scala IDE 2.0.0
    • ADT r16
  • sbteclipse

Android SDK

Android SDK | Android Developersを参考にいつもの手順。

$ wget http://dl.google.com/android/android-sdk_r16-linux.tgz
$ tar xzf android-sdk_r16-linux.tgz
$ mv android-sdk-linux /opt
$ vim ~/.zshrc

export ANDROID_SDK_HOME=/opt/android-sdk-linux
export ANDROID_HOME=/opt/android-sdk-linux
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

$ android

SDK Managerが起動するのでSDK Tools, SDK Platform-tools, SDK Platform, Support packageなど必要なものをインストール

sun-java6

Java SE Downloads

後々、Eclipseで.scalaファイルを開いたらEclipseがクラッシュするという不具合に遭遇したけどOpenJDKからsun-java6に変えたら消えたので必須かも。

$ ./jdk-6u31-linux-i586.bin   
$ sudo mkdir /usr/local/java
$ sudo mv jdk1.6.0_31 /usr/local/java
$ cd /usr/local/java
$ sudo ln -s jdk1.6.0_31 jdk
$ sudo ln -s jdk/jre jre
$ vim ~/.zshrc

export JAVA_HOME=/usr/local/java/jdk
export JRE_HOME=/usr/local/java/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

$ source ~/.zshrc

sbt 0.11.2

sbt 0.12が出ているみたいだけど安牌と思われる0.11.2を選択。 sbt-launch.jarとその起動スクリプトを準備する。

Download sbt-launch.jar and place it in ~/bin.

Create a script to run the jar, by placing this in a file called sbt in your ~/bin directory:

java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -jar `dirname $0`/sbt-launch.jar "$@"

Make the script executable:

$ chmod u+x ~/bin/sbt

https://github.com/harrah/xsbt/wiki/Getting-Started-Setup

conscript, giter8

プロジェクトテンプレート作成用にconscriptおよびgiter8をインストール。このテンプレートをsbtで開くと自動的にandroid-pluginがインストールされる。

$ curl https://raw.github.com/n8han/conscript/master/setup.sh | sh
$ cs n8han/giter8
$ cd my/project/directory
$ g8 jberkel/android-app

Eclipse

Scala IDE 2.0.0ADT Plugin for EclipseInstall New Software...する。

sbteclipse

Getting Started — Scala IDEStart from an existing SBT projectを参考にsbteclipseをインストールする。 /project/plugins.sbtへ次のようにaddSbtPluginを1行追加する。addSbtPluginの間は1行開けないとsbtがエラーを吐く。

resolvers += Resolver.url("scalasbt snapshots", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns)

addSbtPlugin("org.scala-sbt" % "sbt-android-plugin" % "0.6.1-SNAPSHOT")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0")

$ sbt
> eclipse

sbtを実行すると自動でsbteclipseをインストールする。sbt内でeclipseと打つとeclipse用のプロジェクトファイルを生成する。

開発

In Eclipse use the Import Wizard to import Existing Projects into Workspace https://github.com/typesafehub/sbteclipse

Eclipse上でコードを書き、sbtでビルドする。

参考

1 件のコメント:

  1. The symbols featured on this recreation include seashells, gold rings, gem-encrusted crowns, mermaids, dolphins, and the almighty god of the sea – Poseidon. Instead of specializing in the generic suggestions and tips you find on all on line casino guides on the web, it focuses on proven ways to improve your odds when you choose the video games to play. Big Time Gaming are well-known for the Megaways collection of video games - and you 카지노사이트 can play all of the favourites right here at MrQ. 10 spins on Fishin' Frenzy The Big Catch valued at 10p each. Spins credited when referrer and referee deposit & spend £10.

    返信削除