YOU'VE MADE A BRAVE DECISION, WELCOME.

每一个不曾起舞的日子都是对生命的辜负。

总结:IntelliJ-IDEA

IntelliJ IDEA has three compilation types: Compile、Make、Rebuild.

Compile

  • 在指定的范围内进行编译。例如,可以编译一个类、包或模块。
  • 不会编译所依赖的模块。例如,Foo依赖于Bar,Bar先前没有被编译过,那么你去编译Foo则会报错。
  • 不会创建任何artifacts(JARs, WARs, etc.)。

this just complies the files in the specified scope. So you can, for example, compile just a single class or a package (or, of course, a module). It does not transitively compile dependencies. So if Foo has a dependency on Bar, and Bar was not previously compiled, and you go to compile Foo only, the compilation fails. If Bar was previous compiled, but has changed, and you again only compile Foo, it uses the old compiled version and does not recompile the changed Bar class. Compile always compiles everything in the scope (i.e. a clean compile); this includes unmodified classes within the scope. But again, not transitively/recursively. If you compile module “GUI” which has a dependency on module “API”, only GUI is complied. If “API” was not previously compiled (or has changes) the compiling of GUI would fail. Finally, compile only compiles code. It does not create any artifacts (JARs, WARs, etc.)

Make

  • 对模块或项目进行编译,不能编译一个单独的class或package,只能编译修改后的classes。
  • Make可以递归进行编译。
  • 不会创建任何artifacts(JARs, WARs, etc.)。

Make is limited to the module or project level. (i.e. you cannot make a single class or package). It only compiles modified classes. Make, however, will transitively/recursively compile dependencies. Thus, using the above example, if we make “GUI”, it will also make “API” and compile any classes modified since last compilation. When you make a project, some additional tasks that tiled to the make process are performs, such as EJB validation. Finally, make only compiles classes and does not create any artifacts (JARs, WARs, etc.) So the main difference between compile and make is that compile can be performed on a finer level (class or package) and make compiles transitive/recursive dependencies.

Rebuild

  • 编译整个项目,删除所有之前的编译文件。
  • 只能被用在项目层面。
  • 不会创建任何artifacts(JARs, WARs, etc.)。

This performs a full clean make on the project. So unlike make, it deletes all previous compiled objects. Rebuild can only be performed at the project level (so, “No” to answer your question about a module rebuild). Rebuild only compiles classes and does not create any artifacts (JARs, WARs, etc.)

There is also the “Build Artifact” action which allows you to “Build”, “Rebuild” or just clean the artifact. Build only builds it if there is modified code, whereas Rebuild always rebuilds it.

Also of note, in the compiler configuration, you can select to “Make the project automatically” if you have the “Use external build” option selected. The latter simply runs the build in a separate OS process. Therefore you can select the former, and IDEA will automatically make the project in the background. As such, when you go to run code or tests, there is typically little if any code that needs to be compiled.