Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA: Maven, project compilation and deployment

Can someone explain me IntelliJ IDEA's workflow of compilation, deployment and packaging with binded maven project ?

I've encountered some misunderstanding when I'm starting tomcat server via IDEA's debug mode. For example I have one artifact - war archive. As I understand when I'm running debug mode - IDEA recompiles and updates changed code into war-archive.

But what happens with packaged maven artifact ? Does IntelliJ updates it ? Or I have to set 'Buld maven before startup' option to be sure that changed code will be uploaded to environment ?

like image 584
Igor Konoplyanko Avatar asked Feb 24 '11 12:02

Igor Konoplyanko


1 Answers

Intelli J doesn't use maven to build the project it uses its own build process. It uses the pom file as a description of the project.

This means a couple of things, if you want to build an artifact such as a war file when running in tomcat then all you have to do is tell IntelliJ to build the war in the Run/Debug Configurations dialog. IntelliJ will automatically build any artifacts you specify under the deployment tab of your run/debug configuration. So if you specify the exploded war it will build the exploded war, if you specify the regular war it will build the regular war.

Occasionally people need to run custom plugins or build targets in which case you can configure IntelliJ to run the custom maven goals.

You can also tell intellIJ to run the maven package goal rather than build the artifact. IntelliJ will deploy whatever is under the target directory to tomcat.

The important take away is IntellIJ is using two separate build systems. You need to tell each build system what to do. And you need to tell IntelliJ which build system to use for what. IntelliJ will by default use it's own build system once a project has been imported, unless you tell it to use maven for something.

While IntelliJ will build the artifact you specify in the pom file it won't do things like deploy them your artifact repository (local or other wise) unless you click on the deploy target in the Maven tools window.

Also if you change your pom file and don't have auto re-import enabled those changes won't be reflected in your project until you click the force re-import option from the maven tools window.

like image 184
Karthik Ramachandran Avatar answered Sep 22 '22 01:09

Karthik Ramachandran