Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] Java packages and directory structure

We have recently switch over to using Eclipse in our team (after I
downloaded it at home for quick evaluation, and soon realised that the tool
rocks :)

However we have come across a bit of a stumbling block WRT package name vs
directory names.

We use JUnit tests throughout our system, and have adopted quite a standard
approach to the source organisation of the Unit Tests.

Given a package:
With an (interface) and (class) and	(all have package decleration "package

We wish to create 2 unit test classes  and

And while we want the unit tests to live in the package
com.SSMB.cmfapps.repository (along side the interface and 2 classes), we
want to keep the source in a different directory (a subdirectory called


*But* the package for these test classes should not be
com.SSMB.cfmapps.repository.test, just com.SSMB.cfmapps.repository.  I.e.
the source lives in a separate directory, but the compiled classes live in
the same package as the classes they are testing!  This makes it nice and
easy to track Unit Test coverage and navigate/run unit tests relative to the
given class, but also easy for us to ignore the /test directories when
building for deployment to production servers.

Eclipse (like a few other IDE's) seems to dislike this idea, it keeps
erroring/warning claiming "The declared package does not the expected
package com.SSMB.cfmapps.repository.test"

Is there anyway for us to turn this off, and ideally using pattern matching,
e.g. Ignore directory/package name mismatch = "**/test" so that any java
file that lives in a directory tree ending in '/test' should be ignored for
package-directory checking.

Either way, the net result we expect is that the project should compile
without problems in this situation, and that after compilation we should be
able to browse to ${project.src}/com/SSB/cfmapps/repository and find

Thanks for any help in advance, and I will say it again "Eclipse & JDT rock"


Back to the top