I'de like to distribute a Java package that I've written under some permissive license.

The resulting speedytools-0.1.jar has some common Java dependencies like Apache Commons and Guava.

What is the most Java-esque way to distribute this jar? Should I include the dependencies in my distributed zip file?

有帮助吗?

解决方案

You shouldn't include dependencies into your jar. Just declare them as maven dependencies.

This will give several advantages:

  • Users can use your library in conjunction with standalone Guava of any backward compatible version.

  • User can reduce dependencies count by excluding Guava transitive dependency from your library if he uses parts of your library, that don't depend on Guava.

其他提示

jarjar: "Embedding java libraries since 2004."

  • You don't have to worry about your library depending on a specific version of a dependency, which may conflict with the dependencies of another library.

  • You can freely change your libraries should you add a dependency in a future release - users won't have to reconfigure their build scripts.

  • You can patch the libraries to fit your needs: If you want a special build of one of those common Java dependencies, then hack away - your build doesn't even need to be compatible with the public version.

  • It makes the entire process of downloading and implementing your package exceedingly simple. The degree to which this is beneficial (or even desirable) depends obviously on what your package is, what it does and who you want it to do it for. Admittedly, I'd favor the maven solution in most of the use-cases I can imagine - but nonethess, I think jarjar definitely has a place in a question as open-ended as this one, as there are certainly still use cases for which it is ideal.

ps great question, looking forward to seeing other answers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top