How to build jars from IntelliJ properly?

前端 未结 20 2498
盖世英雄少女心
盖世英雄少女心 2020-11-22 01:14

I have a project that contains a single module, and some dependencies. I\'d like to create a jar, in a separate directory, that contains the compiled module. In addition, I\

20条回答
  •  忘了有多久
    2020-11-22 01:52

    Some of the other answers are useless because as soon as you re-import the IntelliJ IDEA project from the maven project, all changes will be lost.

    The building of the jar needs to be triggered by a run/debug configuration, not by the project settings.

    Jetbrains has a nice description of how you can accomplish this here:

    https://www.jetbrains.com/help/idea/maven.html

    Scroll down to the section called "Configuring triggers for Maven goals".

    (The only disadvantage of their description is that their screenshots are in the default black-on-white color scheme instead of the super-awesome darcula theme. Ugh!)

    So, basically, what you do is that you open the "Maven Projects" panel, you find the project of interest, (in your case, the project that builds your jar,) underneath it you find the maven goal that you want to execute, (usually the "package" goal creates jars,) you open up the context menu on it, (right-click on a Windows machine,) and there will be an "Execute before Run/Debug..." option that you can select and it will take you by the hand from there. Really easy.

提交回复
热议问题