IntelliJ IDEA: Maven, project compilation and deployment

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.

Leave a Comment