How to create single jar file from github tree?

梦想的初衷 提交于 2019-12-21 20:46:24

问题


For example, the Java API for pubnub is at https://github.com/pubnub/pubnub-api/tree/master/java

I want to create a single jar file from all the java files in the subfolders.

What is the most straight-forward way to do that?


回答1:


Since Pubnub provided no build file, you need to create a new java project in your favourite IDE and then import the downloaded java code. Next, you can compile and package the project into jar file using the IDE.

Note: it is also possible to create a build script yourself but it is more complicated.




回答2:


Since you want a single jar file, then the easiest way to do this is to follow the next few steps:

  1. Create a Maven project in, say NetBeans. I typically make the same name as it is on the public repository. In this case I recommend "pubnum".

  2. Pull the source from a GIT repository into the project you've created in the step #1. This part is tricky because the source in the GIT repository may not follow Maven conventions... If it does not, you must restructure it. Read about Maven directory structure.

  3. Make sure the Maven shade plugin is installed, and you are ready to roll. Just execute maven shade:shade and, if everything goes well, you'll get the jar file.



来源:https://stackoverflow.com/questions/8300813/how-to-create-single-jar-file-from-github-tree

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