Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse project hiding src folder

For some reason Eclipse has started hiding the 'src' folder in some but not all of my projects and I would like to get it back.

The files under src are still available under other generated views such as Java Resources and Deployed Resources but the actual 'src' folder is hidden from all views including Project Explorer, Navigator, and Open Resource (Ctrl+Shift+R). Not being able to navigate via Open Resource is particularly annoying.

Does anyone know why the folder has disappeared, and how to get it back?

I have a feeling I changed a setting somewhere a while ago not realising the side effects but am really struggling to how to undo this change. Other people on my team are unaffected so I assume it is a setting somewhere on my machine.

The projects in question are all Spring Maven projects using m2e. The two affected projects are both webapp/WAR projects but other webapp projects are unaffected.

Things I've tried to whittle down the cause:

  • With and without the Spring Tool Suite plugin.
  • Clean install of Eclipse JavaEE with no additional plugins.
  • Deleting and recreating my workspace.
  • Clean source checkout.
  • Removing any .project, .classpath, .settings files from the checkout.
  • Deleting and reimporting all projects via Maven.
  • Disabling all Filters in Project Explorer and Navigator.
  • Diffing the generated .project and .settings files between the projects with no obvious differences.

Software details are:

  • Debian 7, 64-bit
  • Oracle JDK 1.7u25 64-bit.
  • Eclipse Kepler, Java EE version, Linux 64-bit.
  • m2e 1.0 as supplied with Kepler

screenshot

like image 713
bamason Avatar asked Aug 21 '13 05:08

bamason


People also ask

What is src folder in Eclipse?

src is where Java IDEs (at least Eclipse and NetBeans) put the source files, it is pretty much standard, and the hierarchy of the folder inside it has to match your Java packages names.

What is an src folder?

The src stands for source. The /src folder comprises of the raw non-minified code. The /src folder is used to store the file with the primary purpose of reading (and/or editing) the code. The /src folder contains all the sources, i.e. the code which is required to be manipulated before it can be used.

How do I show all folders in Eclipse?

To view the project explorer, click on Window menu then, click on Show View and select Project Explorer. There is simpler way to open project explorer, when you are in the editor press alt + shift + w and select project explorer.


2 Answers

  • right click on project

  • select properties

  • select java build path

  • goto source tab

  • click add folder

  • select your source folder (src/main/java)

I would also add src/main/resources, src/test/java, src/test/resources

like image 149
jmj Avatar answered Oct 03 '22 11:10

jmj


Answering my own question to help out anyone else who gets this since it has wasted a couple of days of my time figuring out the cause.

Someone on my team accidentally checked in a .git folder somewhere deep under src/main/webapp which triggers the problem when importing the project. Removing the stray .git folder fixes the problem.

I assume this confuses the EGit plug-in which ships with the Java EE version of Eclipse. We don't use Git so I had no reason to suspect it as the cause of the problem. No one else on the team saw the problem since it only shows up when re-importing projects.

Hope to submit a bug report to the EGit project at some stage since I can't think why it should ever hide the 'src' folder like this.

like image 25
bamason Avatar answered Oct 03 '22 12:10

bamason