class Derby < Formula desc "Apache Derby is an embedded relational database running on JVM" homepage "https://db.apache.org/derby/" url "https://www.apache.org/dyn/closer.cgi?path=db/derby/db-derby-10.13.1.1/db-derby-10.13.1.1-bin.tar.gz" mirror "https://archive.apache.org/dist/db/derby/db-derby-10.13.1.1/db-derby-10.13.1.1-bin.tar.gz" sha256 "74c35d7ec859b8438e69fd0d1b415dd4f4572f71d2f35fc612f2f21848eef3b3" bottle :unneeded depends_on :java => "1.6+" def install rm_rf Dir["bin/*.bat"] libexec.install %w[lib test index.html LICENSE NOTICE RELEASE-NOTES.html KEYS docs javadoc demo] bin.install Dir["bin/*"] bin.env_script_all_files(libexec/"bin", Language::Java.overridable_java_home_env.merge(:DERBY_INSTALL => libexec.to_s, :DERBY_HOME => libexec.to_s)) end def post_install (var/"derby").mkpath end plist_options :manual => "DERBY_OPTS=-Dsystem.derby.home=#{HOMEBREW_PREFIX}/var/derby #{HOMEBREW_PREFIX}/bin/startNetworkServer" def plist; <<-EOS.undent KeepAlive Label #{plist_name} ProgramArguments #{opt_bin}/NetworkServerControl -h 127.0.0.1 start RunAtLoad WorkingDirectory #{var}/derby EOS end test do assert_match /OS name: Mac OS X/, shell_output("#{bin}/sysinfo") pid = fork do exec "#{bin}/startNetworkServer" end begin sleep 4 exec "#{bin}/stopNetworkServer" ensure Process.wait(pid) end end end