如何告诉 Homebrew 公式只对 bin 下的符号链接文件?

How to tell a Homebrew formula to only symlink files under bin?

我正在将 java 应用打包为 Homebrew 公式。

我的公式里有这个

  def install
    bin.install "bin/my-app"
    lib.install Dir["lib/*.jar"]    
  end

它工作正常,但最终将所有 jar 文件符号链接到 /usr/local/lib/。 我看到 keg_only 选项。然而,这也将阻止 bin/my-app 被符号链接到 /usr/local/bin.

我可以说 "Install the bin as you normally do, but these libs need to only live in the Cellar for my app." 吗?

我在 Homebrew forum

收到了答复

Consider installing the JARs in libexec instead:

libexec.install Dir["lib/*.jar"]

and adjust the necessary paths in my-app (I assume it’s a typical Java launcher script). That’s a fairly common pattern in Java formulas.

这就是我现在拥有的

  def install
    bin.install "bin/my-app"
    libexec.install Dir["lib/*.jar"]

    inreplace "#{bin}/my-app", '/lib/', '/libexec/'
  end