giter8 0.7.1

enable bottling
add :java requirement
do a complete installation in libexec using upstream's `conscript` tool
remove the caveat since it's no longer applicable
add a test

Closes #4205.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
This commit is contained in:
ilovezfs 2016-08-24 01:17:16 -07:00
parent 2e1576eb07
commit 2cfe271e0f

View file

@ -1,53 +1,51 @@
class Giter8 < Formula
desc "Generate files and directories from templates in a git repo"
homepage "https://github.com/n8han/giter8"
url "https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.7/sbt-launch.jar"
version "0.6.8"
sha256 "9673ca4611e6367955ae068d5888f7ae665ab013c3e8435ffe2ca94318c6d607"
# note: because sbt-launch dynamically downloads giter8 from the maven repos
# at first run (using the launchconfig mechanism), and not when the formula
# is installed, the above url and sha256 are related to sbt-launch.jar.
# The version below is that of giter8, and when upgrading this formula,
# one must check the giter8 version is available in maven repositories.
url "https://github.com/foundweekends/giter8/archive/v0.7.1.tar.gz"
sha256 "181357720f14b49cf132210a04fe3ad470d51731030394a8a723c1c49aced42c"
bottle :unneeded
depends_on :java => "1.6+"
def exec_script; <<-EOS.undent
#!/bin/sh
exec java -Xmx512M -jar #{prefix}/sbt-launch.jar @giter8.launchconfig "$@"
EOS
resource "conscript" do
url "https://github.com/foundweekends/conscript.git",
:revision => "f7ee8b5bc3b00592adbd09c878b6649b624f141c"
end
def config_script; <<-EOS.undent
[app]
version: #{version}
org: net.databinder.giter8
name: giter8
class: giter8.Giter8
[scala]
version: 2.10.4
[repositories]
local
maven-central
sonatype-releases: https://oss.sonatype.org/content/repositories/releases/
[boot]
directory: #{prefix}/boot
EOS
resource "launcher" do
url "https://oss.sonatype.org/content/repositories/public/org/scala-sbt/launcher/1.0.0/launcher-1.0.0.jar"
sha256 "9149549ee09c50bda21ab57990f95aac4dd3919d720367df6198ec7e16480639"
end
def install
(bin/"g8").write exec_script
(prefix/"giter8.launchconfig").write config_script
prefix.install "sbt-launch.jar"
conscript_home = libexec/"conscript"
ENV["CONSCRIPT_HOME"] = conscript_home
ENV.java_cache
conscript_home.install resource("launcher")
launcher = conscript_home/"launcher-#{resource("launcher").version}.jar"
conscript_home.install_symlink launcher => "sbt-launch.jar"
resource("conscript").stage do
cs = conscript_home/"foundweekends/conscript/cs"
cs.install "src/main/conscript/cs/launchconfig"
inreplace "setup.sh" do |s|
s.gsub! /.*wget .*/, ""
s.gsub! /^ +exec .*/, "exit"
end
system "sh", "-x", "setup.sh" # exit code is 1
end
system conscript_home/"bin/cs", "foundweekends/giter8/#{version}"
bin.install_symlink conscript_home/"bin/g8"
end
def caveats; <<-EOS.undent
Giter8 will download the Scala runtime and the rest of the
giter8 binaries the first time you run it.
You can do that now by running "g8".
If the download of a resources fails, try cleaning your
~/.ivy2/cache folder and rerun / reinstall giter8.
EOS
test do
# sandboxing blocks us from locking libexec/"conscript/boot/sbt.boot.lock"
cp_r libexec/"conscript", "."
inreplace %w[conscript/bin/cs conscript/bin/g8
conscript/foundweekends/giter8/g8/launchconfig
conscript/foundweekends/conscript/cs/launchconfig],
libexec, testpath
system testpath/"conscript/bin/g8", "--version"
end
end