IntelliJ mvn package behaves differently than on the command line

In my project, when I go to the cmd line and type:

mvn package

Creates a single .jar file in my / target directory.

I am using the maven shade plugin.

I want to be able to do this in IntelliJ, so in my startup configurations for maven I set the working directory to the root pom.xml folder and I added the command line "mvn package".

It does not produce the same output, it just has:

classes generated-sources generated-test-sources test-classes 

What am I doing wrong?

+4
source share
1 answer

As the error says, you entered an erroneous life cycle since you also included the mvn command. This command will be implicitly called (since this is the maven startup configuration).

Here is what you have:

enter image description here

This gives you something like this as an error:

 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.118s [INFO] Finished at: Sun Jun 16 15:47:29 CEST 2013 [INFO] Final Memory: 6M/120M [INFO] ------------------------------------------------------------------------ [ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1] 

So just remove the mvn command and do this:

enter image description here

Your build will now be correct.

+21
source

Source: https://habr.com/ru/post/1486298/


All Articles