Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

So an Eclipse Maven project has to obey both conventions. The src/main/java and src/main/resources subdirectories will be configured as Build Path Source directories (and maybe also the test directories). The default output directory will be target/classes. This happens automatically when a Maven project is digested and turned into an Eclipse project by the Eclipse Maven plugin.

...

Java Source Files Appear Twice in

...

the Project

When you designate a particular directory to be an Eclipse Build Path directory is configured as a Java Source directory, then the Java source files under it is in the first group of directories listed for that project in the Project Explorer view. Image RemovedIn this example, the source directory src/main/java appears as the first thing in the project, and if you expand it you find the appear twice in Project Explorer. Under the "src" subdirectory they appear as ordinary files, just as if they were text or html. This is generally not the useful version of the file and should be ignored. The better file listing occurs first in a special view of configured Source directories. Here information is displayed in Java language terms. So the Package name org.jasig.cas.adapters.jdbc is displayed in dotted notation as you would find in a Java package statement, instead of displaying each element of the path as a directory as in "org/jasig/cas/adapters/jdbc". It is in the Source directory display that Eclipse knows this is a Java program and has access to the specific Java language tools for editing and debugging.

Image Added

In this example:

  1. the top line is the cas-server-support-jdbc Project
  2. it is followed by the src/main/java source directory
  3. that contains the org.jasig.cas.adaptors.jdbc Java package

...

  1. which in turn contains four

...

  1. Java source files

After two lines that show the dependencies and libraries, src appears a second time as a disk subdirectory of the project. Because this is the disk file view, there is no aggregation of package names using the Java x.y.z notation. Instead, each naming level is shown in its raw form as a directory on disk. Eventually the four Java source files are shown a second time, but now as ordinary files on disk rather than Java source files.

What is the difference between the two? When the Java files are first listed, they are preceded by the little triangle icon that means they can be opened further as a tree. If you open one, you find a class and if you open the class you find fields:

Image Added
Whereas, down in the file display the same Java source file name has no tree icon. Viewed as a file instead of Java source, the source file is the bottom of the hierarchy and has no contents.

In this example, the four Java source files show up twice in the cas-server-support-jdbc project. However, as you either have already discovered or will shortly discover (depending on the order in which you read all the pages of this document) the actual project files are subdirectories of the cas3 (or cas-server) project. That is where they are physically located, while the cas-server-support-jdbc project is a view into that physical directory. So if you looked up in the first project (cas3) you will also find the same four files under cas3/cas-server-support-jdbc/src/main/java/...

While the source directories show up twice (once as java source files in packages and once as plain files on disk) the output directory of target/classes doesn't show up at all. From the Project Explorer you might imagine that there is not classes subdirectory of target, but if you open the workspace from outside Eclipse and navigate to the cas3/cas-server-support-jdbc/target directory you will find that classes is really there. This is an Eclipse trick to "hide" the output directory and all the *.class files it generates so the user isn't bothered by them. Eclipse wants the user to see things as source-only.