気ままなつぶやき

おべんきょしたこととか

【Homebrew】playframework 1系をインストール

ひさしぶり。

もともとplayの2系が入っていたんだけど、1系もmacに同居させたい需要ができたのでインストールした。

今入ってるのは、play2.1.3

playのダウンロードページより、1系の一番新しいものを入れた
http://www.playframework.com/download

Formulaの作成

$ brew --version
0.9.5
$ brew create http://downloads.typesafe.com/play/1.2.7/play-1.2.7.zip --set-name play1

formulaの編集画面がでるので、こんな感じにした。
playコマンドで2系が実行されるので、1系はplay1で実行できるようにしている

require 'formula'

class Play1 < Formula
  homepage 'http://www.playframework.org/'
  head 'https://github.com/playframework/play1.git'
  url 'http://downloads.typesafe.com/play/1.2.7/play-1.2.7.zip'
  sha1 '436739d9f7cc00567a7e4245413c9c1ebf886797'

  def install
    system "./framework/build", "publish-local" if build.head?

    # remove Windows .bat files
    rm Dir['*.bat']
    rm Dir["#{buildpath}/**/*.bat"] if build.head?

    libexec.install Dir['*']
    bin.install_symlink libexec/'play' => "play1"
  end

end

構文のチェック

$ brew doctor play1
Your system is ready to brew.

大丈夫そう。

インストール

$ brew install play1
==> Downloading http://downloads.typesafe.com/play/1.2.7/play-1.2.7.zip
Already downloaded: /Library/Caches/Homebrew/play1-1.2.7.zip
🍺  /usr/local/Cellar/play1/1.2.7: 3110 files, 98M, built in 4 seconds

確認

$ play1
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.7, http://www.playframework.org
~
~ Usage: play cmd [app_path] [--options]
~
~ with,  new      Create a new application
~        run      Run the application in the current shell
~        help     Show play help
~

おまけ

paginate-head

プロジェクト配下で

play1 dependencies

と打ったら

~ Module not found: /usr/local/Cellar/play1/1.2.7/libexec/modules/paginate-head

っていうエラーがでた。

play install でモジュールインストールして

~ You can now use it by adding it to the dependencies.yml file:
~
~ require:
~     play -> paginate head

これ対応すればよい

以下ログ

$ play1 install paginate-head
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.7, http://www.playframework.org
~
~ Will install paginate-head
~ This module is compatible with: 1.x
~ Do you want to install this version (y/n)? y
~ Installing module paginate-head...
~
~ Fetching http://www.playframework.org/modules/paginate-head.zip
~ [--------------------------100%-------------------------] 18370.8 KiB/s
~ Unzipping...
~
~ Module paginate-head is installed!
~ You can now use it by adding it to the dependencies.yml file:
~
~ require:
~     play -> paginate head