Build multi-platform executable for a SWT application using maven

我只是一个虾纸丫 提交于 2019-11-29 10:58:29

I've done this using Maven by studying JackRabbit's setup. JackRabbit is delivered in all kinds of forms (standalone, OSGi bundle, webapp, etc.) and it is all done from one aggregator pom.

The first step is to separate your parent pom with profiles and common dependencies from an aggregator pom which defines the (order of the) sub-modules of your project. The first sub-module in the aggregator pom is usually the parent-pom. The advantage of the aggregator pom is that you can run Maven with the aggregator pom to build everything for your project in one go.

Next I created a "common assembly resources" project which produces a jar with all resources (e.g. readme, manual, pictures, etc.) which are used in all assemblies for a platform. Each platform assembly project extracts this jar and then copies the extracted files to a proper location. JackRabbit does not do this as far as I can see, so you can probably skip this step.

Finally, for each platform a separate platform-assembly sub-module is created. In the platform-assembly you can set which dependencies you want and do not want. The sub-module can contain files specific for the platform (e.g. batch-files for Windows, .sh-files for Linux). The assembly form can be made specific for the platform (e.g. .zip for Windows and .tar.gz for Linux). For Windows I also included NSIS to create a setup.exe (which you can also build on Linux with the NSIS-package installed).

I've used the maven-dependency-plugin a lot in this setup with different phases. One I often use is phase process-resources, you can try that instead of phase package.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!