Reputation: 325
(Java 101 -- probably so simple a question that I can't find an answer because everyone assumes it's so obvious.)
I'm using eclipse. I went to open what I thought was a project. I did not realize that, in fact, it was a directory with several projects in it. As a result, eclipse iterated through and opened each of them as separate projects in my Package Explorer panel. That got me thinking: on what basis did eclipse decide that the root directory was NOT a project, and that the individual dirs within the root directory were projects?
EDIT: Thanks everyone for their answers so far, but I'd still like to have something clarified. OK -- if I create the project in eclipse then it will add a .project
file (and other IDEs might add their own convention files), but what happens if I did not create a project in an IDE -- it's just dirs and plain source files; would eclipse (or any IDE) thereby be able to discern that a given dir is a 'project'?
Upvotes: 1
Views: 117
Reputation: 111142
The presence of a valid .project
file in a directory makes it an Eclipse project. If there is no .project
file Eclipse will not recognise this as an Eclipse project.
Package/Project Explorer don't normal show files starting with '.' so you won't see these files unless you change the Explorer filter settings.
The .project
is an XML file which contains the basic details about the Eclipse project. It contains things like the project 'nature' which says that it is a Java project or a Plug-in project or whatever.
The most basic .project
for a 'general' project looks like:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>General Project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
A Java project looks like:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Java Project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
which adds the Java nature and the command for building Java code.
Different project types may add other '.' files. For example, a Java project will have a .classpath
file containing the Java classpath settings.
Upvotes: 2
Reputation: 19
In this case, you need to go one level deeper and set the root directory as an individual project within the original directory. The .project
and .classpath
files in a project are how Eclipse determines if a directory is a project.
Upvotes: 0
Reputation: 1089
Eclipse actually creates invisible files containing metadata about the project
Upvotes: 0