Intellij exclude file from being compiled

2019-01-18 14:16发布

问题:

I am trying to exclude a particular file in my project from being compiled.

According to the Intellij IDEA documentation you do this by "marking the file as plain text".

However, the context menu in the project view where this functionality is supposedly located has no such action. I am using version 13.02 of Intellij. Here is what my context menu looks like:

回答1:

Under File > Settings > Build, Execution, Deployment > Compiler > Excludes, add an entry.

Any attempts to run a path specified here will result in a ClassNotFoundException, and a very important class indicator as well.



回答2:

Just to compound on Makoto's answer (would comment but don't have reputation), it looks like this feature does not apply to classes (.java) or assets (images)...for these types of files, it looks like you will need to actually go to the compiler and explicitly state that the file(s) should be excluded.

However, for .htm, .xml, or really anything that isn't a class or asset you will find and can use the 'Mark as plain text' option.

Edit: It looks like you can also go to the 'Messages Make' error / warnings view and Exclude from there, a little less work IMHO.