homebrew-core/Formula/leiningen.rb

67 lines
2.1 KiB
Ruby

class Leiningen < Formula
desc "Build tool for Clojure"
homepage "https://github.com/technomancy/leiningen"
url "https://github.com/technomancy/leiningen/archive/2.9.10.tar.gz"
sha256 "55e7d1d89eb3b16309b3b7936e72bcdfb783aea80c60908b50b22781bae911c4"
license "EPL-1.0"
head "https://github.com/technomancy/leiningen.git", branch: "master"
bottle do
sha256 cellar: :any_skip_relocation, all: "32563f54ee6abeea79637fcaf0858ae9c0eebb3110fac1e166e1c9868b2a18bc"
end
depends_on "openjdk"
resource "jar" do
url "https://github.com/technomancy/leiningen/releases/download/2.9.10/leiningen-2.9.10-standalone.jar"
sha256 "a228530f00b50753acfddc3de38a0d737b6f5c1aec49af202e70a0ad28c249c9"
end
def install
libexec.install resource("jar")
jar = "leiningen-#{version}-standalone.jar"
# bin/lein autoinstalls and autoupdates, which doesn't work too well for us
inreplace "bin/lein-pkg" do |s|
s.change_make_var! "LEIN_JAR", libexec/jar
end
(libexec/"bin").install "bin/lein-pkg" => "lein"
(libexec/"bin/lein").chmod 0755
(bin/"lein").write_env_script libexec/"bin/lein", Language::Java.overridable_java_home_env
bash_completion.install "bash_completion.bash" => "lein-completion.bash"
zsh_completion.install "zsh_completion.zsh" => "_lein"
end
def caveats
<<~EOS
Dependencies will be installed to:
$HOME/.m2/repository
To play around with Clojure run `lein repl` or `lein help`.
EOS
end
test do
(testpath/"project.clj").write <<~EOS
(defproject brew-test "1.0"
:dependencies [[org.clojure/clojure "1.10.3"]])
EOS
(testpath/"src/brew_test/core.clj").write <<~EOS
(ns brew-test.core)
(defn adds-two
"I add two to a number"
[x]
(+ x 2))
EOS
(testpath/"test/brew_test/core_test.clj").write <<~EOS
(ns brew-test.core-test
(:require [clojure.test :refer :all]
[brew-test.core :as t]))
(deftest canary-test
(testing "adds-two yields 4 for input of 2"
(is (= 4 (t/adds-two 2)))))
EOS
system "#{bin}/lein", "test"
end
end