class Neo4j < Formula desc "Robust (fully ACID) transactional property graph database" homepage "https://neo4j.com/" url "https://neo4j.com/artifact.php?name=neo4j-community-3.3.0-unix.tar.gz" sha256 "dbbc65683d65018c48fc14d82ee7691ca75f8f6ea79823b21291970638de5d88" bottle :unneeded depends_on :java => "1.8+" def install inreplace %w[bin/cypher-shell bin/neo4j bin/neo4j-admin bin/neo4j-import bin/neo4j-shell], 'JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"', 'JAVA_HOME="$(/usr/libexec/java_home -v 1.8+)"' ENV["NEO4J_HOME"] = libexec # Remove windows files rm_f Dir["bin/*.bat"] # Install jars in libexec to avoid conflicts libexec.install Dir["*"] # Symlink binaries bin.install Dir["#{libexec}/bin/neo4j{,-shell,-import,-shared.sh,-admin}", "#{libexec}/bin/cypher-shell"] bin.env_script_all_files(libexec/"bin", :NEO4J_HOME => ENV["NEO4J_HOME"]) # Adjust UDC props # Suppress the empty, focus-stealing java gui. (libexec/"conf/neo4j.conf").append_lines <<~EOS wrapper.java.additional=-Djava.awt.headless=true wrapper.java.additional.4=-Dneo4j.ext.udc.source=homebrew EOS end def post_install (var/"log").mkpath end plist_options :manual => "neo4j start" def plist; <<~EOS KeepAlive Label #{plist_name} ProgramArguments #{opt_bin}/neo4j console RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/neo4j.log StandardOutPath #{var}/log/neo4j.log EOS end test do ENV["NEO4J_HOME"] = libexec ENV["NEO4J_LOG"] = testpath/"libexec/data/log/neo4j.log" ENV["NEO4J_PIDFILE"] = testpath/"libexec/data/neo4j-service.pid" mkpath testpath/"libexec/data/log" assert_match /Neo4j .*is not running/i, shell_output("#{bin}/neo4j status", 3) end end