Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ mvn package is behaving differently that command line

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

mvn package

It creates a single fat .jar file in my /target directory.

I am using maven shade plugin.

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

It doesn't produce the same output, it just has:

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

What am i doing wrong?

like image 317
Blankman Avatar asked Jun 14 '13 18:06

Blankman


People also ask

How do I use Maven bundle in IntelliJ terminal?

If you need to use it in your project, install it locally. Specify the file that contains user-specific configuration for Maven in the text field. If you need to specify another file, check Override option, click ellipsis button and select the desired file in the Select Maven Settings File dialog.

Where is the run mvn clean install command in IntelliJ?

Click Run -> Edit Configurations -> Press + -> Search for "Maven" -> Locate "Command Line" field and enter in following maven commands "clean install" -> Press OK. Now click the green button to run that Run/Debug Configuration, this will maven clean install the module/project.

Where is Maven version in IntelliJ?

Go to File -> Settings and use the search bar to find maven settings. There you can find the maven version (usually against the field "Maven home directory" ).


1 Answers

As the error states, you have entered an erroneous lifecycle since you also included the mvn command itself. That command will be implicitly called (since this is a maven run configuration).

This is what you've got:

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 make it look like this:

enter image description here

Your build will now be correct.

like image 116
maba Avatar answered Nov 05 '22 19:11

maba