Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Partial Compilation in IntelliJ IDEA

How do I enable partial compiles in IntelliJ?

The same feature in NetBeans where by one can run a main method in a class without having non-dependecies in the same project be required to also compile.

EDIT:

After performing what CrazyCoder suggested, with some success, now I get ClassNotFoundException when trying to run a file not associated with those that were not compiling. After fixing the non-compiling files, it runs just fine.

I actually made in error in the same non-compiling file to test and it still works.

Could it be a bug?

EDIT:

Followed instructions still not working.

enter image description here

like image 520
BAR Avatar asked May 28 '13 05:05

BAR


People also ask

How do I change compile in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment| Compiler. On the Compiler page, configure settings that are related to any compilation and build process. For example, you can set the automatic compilation for your project.

How do I stop auto compile in IntelliJ?

Open the Setting > Build Tools page. 2. Disable the "Reload changes in build scripts" option.

How do I fix a compilation error in IntelliJ?

Invalidate Caches/Restart. Delete user config. Create a new project (trying to see if my current project files somehow all got messed up, but the problems persist even with new projects) Uninstall + Reinstall.


3 Answers

IntelliJ IDEA doesn't welcome working on the project that fails to compile, but there are several options:

  • use Compile action from the file/folder context menu, disable Build in Run/Debug configuration.
  • in the Before launch section of the Run/Debug configuration remove Build and add Build, no error check instead. Now start the configuration and it will ignore compilation errors trying to run on whatever classes managed to compile. enter image description here

You should note that Make will fail on the first error and will not try to proceed further. In this case you should use explicit Compile action. Make also deletes output class files for the sources with errors.

If you want compilation to proceed after errors, you should switch to Eclipse compiler in IntelliJ IDEA Settings | Compiler | Java Compiler. When Eclipse compiler is selected, Proceed on errors option appears and it's enabled by default. With Eclipse compiler, an option to Proceed on errors enabled and Build, no error check in Before launch section you should get the desired behavior.

like image 177
CrazyCoder Avatar answered Oct 07 '22 22:10

CrazyCoder


Navigate to the Build menu at the bottom of your test editor, right-click on the folder that contains error messages that you find irrelevant.

Choose "Exclude from compile".

Screenshot

like image 6
Nelson Ke Avatar answered Oct 07 '22 21:10

Nelson Ke


To make CrazyCoder comment more visible, if you go for the "proceed on errors" behavior you may want to uncheck

Settings | Compiler | Automatically show first error in editor.

like image 5
Arnaud P Avatar answered Oct 07 '22 21:10

Arnaud P