Depends_on many alternatives?

The current maven.rb Formula have depends_on "openjdk"

Which will install openJDK version 14 as of now.

This creates a mess for people that do not want to deal with multiple java versions.

I for example already have a perfectly fine dependency for maven installed from AdoptOpenJDK/openjdk/adoptopenjdk8

Is there any way to tell the maven.rb (and other java dependent) formulas to be satisfied with both options?

Set JAVA_HOME for or see brew info openjdk for details on how to use arbitrary versions of Java with your software.

Note that Homebrew will always install a copy of openjdk for formulae that require Java. If Java were installed by default on macOS it might be a different story, but users generally expect running brew install maven && mvn to work out of the box, without downloading a separate binary from AdoptOpenJDK or Oracle’s website. See this document for more historical context.

It will always install a specific version of openjdk. The question is if there’s any way for it to assume any version and just accept the one it alread installed previously.

thanks for the doc, will read it later today

reading the doc, this is about using java from the OS. Which is not what i want.

My original question was more with the goal of sending a fix/patch to the maven.rb formula so that it accepts both brew packages adoptopenjdk8 or openjdk, instead of just one or another.

I guess it is more a question on brew/cask formula syntax/features.

Homebrew is an evergreen package manager. It will always use software with the latest version of it’s dependencies by default. For Java however you have an option to point to old software at runtime by setting JAVA_HOME as is convention in the Java ecosystem. We won’t be accepting patches that make tools depend on anything but the latest acceptable version of their dependencies.

1 Like

Doesn’t really have to do with version. My example was a bad one because i picked adoptopenJDK8, but could have been adoptopenJDK@14. and brew would still try to install openjdk@11.

It’s about two packages that provide the same dependency.

Let’s say maven would like to be satisfied by either of them. Is there a way to describe this in the formula? or is it only dependent on one or nothing?

If this were your own tap you could use optional dependencies to make users pick a dependency. But those are prohibited in homebrew-core.

In summary, there is no way to make a core formula depend on any of a list of dependencies. It has to depend on all specified dependencies.