Eclipse: share code among multiple projects

后端 未结 2 1328
失恋的感觉
失恋的感觉 2021-01-02 03:36

I have different projects in Eclipse (java me midlets) which all need to share code. Currently I duplicate things, but this is not ideal. What is the best way to do this? Th

2条回答
  •  长发绾君心
    2021-01-02 04:16

    Have you considered creating a shared library instead of just shared code? Export to a JAR file and import that into the dependent products.

    The up-side of doing this (vs just referencing the shared code) is that it will force you into more rigorous practices. You will now have an API that must be maintained and versioned cleanly. It will also make you better consider what's shared and what's not. This will likely lead to better encapsulation, and hopefully better testing.

    I'm not saying you lack these things now. Just that creating a common-foo.jar can often encourage better habits.

提交回复
热议问题