简体   繁体   中英

Intellij Idea compiler recompiles already compiled project

I use maven command which cleans,builds whole project, creates war and deploys to server. I cannot use Intellij to do that since I have only Community edition. It builds the project in same directory as intellij.

To speed things up I wrote a script which finds compiled files in local "target" directory which are newer than the ones in server and copy them. It all works okay but the problem is Intellij does not see classes compiled with maven as the ones it should skip and rebuilds whole project all over.

Currently it works like this:

  1. Manually in terminal build whole project with maven
  2. Go back to intellij -> make project
  3. Rebuilds all
  4. Run script -> it swaps all files

What I am trying to achieve:

  1. Manually in termin build whole project with maven
  2. Go back to intellij. Change one file -> make project
  3. Compiles only one java file
  4. Run script -> it swaps only one .class file

So the problem is how do I make intellij treat files already compiled with external tool as compiled?

You don't. IntelliJ IDEA has its own incremental compilation system which tracks the dependencies between files being compiled and recompiles the minimum set of classes for every set of changes. External compilation with tools like Maven or Gradle does not update IntelliJ IDEA's incremental compilation database. Because of that, IntelliJ IDEA cannot recognize the fact that classes have been already compiled with an external tool, and will recompile.

That troubled me for long time. Finally, i found this . IDEA build settings You can choose whether use InteliJ or gradle to compile when runnning program. Under gradle project, it uses gradle to build by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM