Should you provide dependent libraries in client jar?

前端 未结 5 627
眼角桃花
眼角桃花 2021-02-02 14:25

We\'re providing a client jar for other internal apps to connect to our app\'s REST API. Our API depends on a few standard Jakarta libraries. Is it a best practice to include

5条回答
  •  伪装坚强ぢ
    2021-02-02 15:03

    The pros of bundling into a single jar are obviously:

    • simplicity for the client

    The cons of bundling are:

    • inability to update the versions of the dependent libraries
    • hiding necessary libraries can actually lead to potential conflicts in the client with those extra libraries
    • complexity for you in the build process (but ways to do this pretty easily in Ant/Maven)
    • some libraries with manifests cannot just be unjared and rejared - you need to actually merge the manifest information. There is Ant and Maven support for this though.

    Another option is to use a single main jar (your code) with the class-path manifest attribute set to suck in the other jars. Personally I don't like this as it's really easy to miss these semi-hidden dependencies.

    In the end, if you're talking just one or two jars, I'd leave them split out. If you're talking 10 or 15, you might want to consider bundling.

提交回复
热议问题