57

In Intellij, if I have an error in a source file, then when building I can choose "Exclude from Compile" by right-clicking on the file in the build output. But, now I would like to include the file again. Where is the menu item that lets me put it back into the build? (The file shows in the Project window, and has a small 'x' in its icon to show it is excluded, but I see no way to get this to go away.)

Edit - I found there is a compiler.xml file, and I found I can delete the file from the "excludeFromCompile" section, but still, there must be a menu item somewhere to do this.

1

14 Answers 14

89

Settings | Compiler | Excludes.

3
  • Note that there is no File | Settings menu option in IDEA v13
    – DJ_Polly
    Jul 10, 2014 at 7:22
  • 3
    @DJ_Polly on Mac it's Preferences or File | Preferences.
    – CrazyCoder
    Jul 10, 2014 at 9:52
  • There is no File | Preferences on mac with intellij 2016.2.
    – gabbler
    Oct 28, 2016 at 7:20
10

For Intellij 14.0 on Windows, undo excludes from compilation

File -> Settings

Then inside Settings -> Build, Execution, Deployment -> Compiler -> Excludes

or just search for "excludes" to find it.

9

Note in IDEA v12, there is no longer a File | Settings menu option. I'm not sure how to exclude/re-include individual files, but this is how it works for folders...

Now the menu item is File | Project Structure... and that brings up a multi-column dialog. In the rightmost column, click Modules, then select the directory that contains the excluded folder in the second column. If it is a folder you are trying to re-include, it is listed in the third column's directory list, and excluded folders are at the bottom, in red. If you click on the red 'X' to the right of the folder name, it will remove the folder from the "excluded" list which has the effect of including it back in the project. Awkward and counter-intuitive, but that's how it works.

5

I found that johnkaplantech's answer didn't work because Idea would complain about multiple modules sharing the same root.

So I manually edited the project files to remove the exclusion. File modified was %ProjectRoot%/.idea/modules/<ModuleName>.iml. Inside module/component/content of this XML file was a tag excludeFolder. Remove that.

2
  • I am on a mac using intellij 2016.2, this is the one works for me.
    – gabbler
    Oct 28, 2016 at 7:17
  • on 2019 community Edition - on Ubuntu Open .idea Folder -> compile.xml .. Its easy to exclude .. but go crazy as how to include ..huh Apr 21, 2019 at 14:49
3

In IntelliJ IDEA 15.0.3 File | Settings | Build, Execution, Deployment | Compiler | Excludes | (Remove path from right list).

2

For Mac it would be :

1) Go to Preferences:

enter image description here

2) Expand Build, Execution,Deployment section

3) Expand Compiler sub section

4) All the excluded classes will be available in the Excludes

enter image description here

5) Delete the classes you want include for compilation and press Ok. Hope it helps.

1

From menu: File | Settings | Compiler | Excludes: you can add/remove excluded files to be compiled in the dialog.

1

For me excluded folders did not appear neither under File > Settings> Compiler > Excludes nor File > Project Structure > Modules > Sources > Exclude.

What I did was: I clicked on the excluded folder with right-click of the mouse. In the menu which opened there is an option "Mark Directory as". I chose "Not Excluded".

0

A simple workflow is to create a directory in your project and exclude the entire directory.. For example, create a directory called, 'excluded'... add files to exclude... right click directory > mark directory as excluded... If you want to add or remove files from that directory reverse the process... cancel exclusion on the directory, get/put files... mark as excluded again.

0

To configure classes to be excluded from import open:

  • Editor / General node, then click Auto-Import.

This works for me. You can also find this in the documentation:

documentation

1
  • links can change with time, provide the essential part of the answer here.
    – krishan
    Jul 10, 2017 at 6:57
0

IntelliJ was still excluding a file after I removed it from the compiler exclude folder. It turns out I had also excluded it in File > Project Structure > Modules > Sources > Exclude files (at the bottom of the window).

0

Nothing to worry about. Simply follow this steps Mac/ windows

  1. File > Settings >
  2. Build, execution, deployment > Excludes
  3. Select the file that you selected as exclude from compile (mistakenly)
  4. Finally delete it and Press ok.
  5. Now you can run the program/code again.

Congratulations!! Problem solved

0

I had the same problem of exclude things, and my solutions where: Tuve el mismo problema de sacar sin querer cosas que no debía y mi soluciones fueron:

Case 1:

IntelliJ IDEA ->Preferences -> Build,Excecution, Deployment ->Build Tools (my case) -> Maven -> Maven ->IgnoredFiles (uncheck the relevant option )

Caso 1: Me pasó lo mismo y mi solución fue ir (en Mac) a: IntelliJ IDEA ->Preferences -> Build,Excecution, Deployment ->Build Tools (en mi caso) -> Maven -> IgnoredFiles (destildar la opción, en mi caso el file en cuestión


Case 2: IntelliJ IDEA ->Preferences -> Build,Excecution, Deployment -> Compiler -> Excludes and select the relevant option -> minus or plus

Caso 2: IntelliJ IDEA ->Preferences -> Build,Excecution, Deployment -> Compiler -> Excludes and select the relevant option -> clickear en el signo más o en menos según corresponda

0

Up-to-date in 2023:

  1. Go to Editor > File Types > Ignored Files and Folders tab
  2. Remove the file/folder pattern you want to include again.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.