Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between intellij Project make and Maven Compile?

When working in maven module, what's the difference between doing in intellij build -> Make Project and Maven Projects -> Root pom -> Compile phase.

Does intellij calls maven? Does both of them compile the sources to the same place? Do they both copy resources files? Why do we need both options? Does intellij download the dependencies automatically and we can just call project make, without using maven compile?

intellij project: two ways of compiling

like image 900
omer727 Avatar asked May 11 '15 11:05

omer727


People also ask

Does IntelliJ build use Maven?

Maven projects IntelliJ IDEA lets you manage Maven projects. You can link, ignore projects, synchronize changes in Maven and IntelliJ IDEA projects, and configure the build and run actions.

What is difference between Maven installation and compile?

mvn test-compile: Compiles the test source code. mvn test: Runs tests for the project. mvn package: Creates JAR or WAR file for the project to convert it into a distributable format. mvn install: Deploys the packaged JAR/ WAR file to the local repository.

How do I compile a project in IntelliJ?

Select a module or a project you want to compile and from the main menu, select Build | Build Project ( Ctrl+F9 ). IntelliJ IDEA displays the compilation results in the Review compilation and build output.

How do I create a project as Maven project in IntelliJ?

In the Project tool window, right-click your project and select Add Framework Support. In the dialog that opens, select Maven from the options on the left and click OK. IntelliJ IDEA adds a default POM to the project and generates the standard Maven layout in Project tool window.


2 Answers

They are actually quite similar in terms of the task they perform which is to compile the source and test paths of the project with javax.tools.JavaCompiler by default.

Does intellij call maven?

No it doesn't by default. Remember that this is just IntelliJ's built in Java compiler and some Java projects don't use maven.

Does both of them compile the sources to the same place?

Yes, they use the same source files to compile if that's what you are asking here.

Do they both copy resources files?

Yes they both copy the resource files to different locations though.

Why do we need both options?

We don't need both options. Maven compile command checks the source code against any syntactical errors which effectively covers the work done by IntelliJ's make option.

Does intellij download the dependencies automatically and we can just call project make, without using maven compile?

Intellij's compiler can be considered as syntax compiler which is why you need maven to handle your project's dependencies.

like image 131
Korhan Ozturk Avatar answered Sep 22 '22 09:09

Korhan Ozturk


No, IntelliJ doesn't call maven, but get all information from the pom.xml e.g. output directories libraries etc.

So don't worry, you can call make from IntelliJ for compiling and running your application. If you have some special goals in your maven build file you can run it from the maven window.

All maven dependencies will be downloaded from IntelliJ an stored in the maven local repository.

like image 43
chokdee Avatar answered Sep 23 '22 09:09

chokdee