59

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

Community
  • 1
  • 1
omer727
  • 7,117
  • 6
  • 26
  • 39

3 Answers3

42

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.

Korhan Ozturk
  • 11,148
  • 6
  • 36
  • 49
  • 11
    When asking "Does both of them compile the sources to the same place?" I meant where is the output location? How do you know intellij copy resources to different locations? Can you elaborate some more. – omer727 May 11 '15 at 19:11
4

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.

chokdee
  • 446
  • 4
  • 13
  • 4
    IntelliJ starts a process in which it uses embedded Maven libraries to download and resolve dependencies, and for parsing of the pom and stuff. So technically it calls Maven, but not for compilation and not via command line but it uses jars directly. – Meo May 11 '15 at 12:00
  • Sure, but it doesn't call maven as an external program, that was the question wasn't it? E.g in gradle projects Intellij call gradle.... – chokdee May 11 '15 at 12:02
  • Yep, but there was also the last question ```Does intellij download the dependencies automatically and we can just call project make, without using maven compile?``` which you did not answer :) – Meo May 11 '15 at 12:06
  • 1
    Looking into sources, there is a ```maven-jps-plugin``` module which contains compilation related stuff, so I was probably wrong in the first comment. Some IntelliJ developer would tell us more. – Meo May 11 '15 at 12:12
2

Let's think we have a Project A which is use Maven Project B.

If you had changed B project you have to update this project on A. Then you have to compile B in A.

But if you had changed only A you dont have to compile Maven.

hurricane
  • 6,521
  • 2
  • 34
  • 44