tags:

views:

261

answers:

9

We have a developer who is in the habit of committing non-java files (xsd, dtd etc) in the java packages under the src/java folder in our repository. Admittedly, these are relevant files to that package, but I just hate to see non-java files in the src folder.

Is this is a common practice that I should get used to or are we doing something strange by maintaining these files like this?

A: 

Its pretty common, you can find it in really popular frameworks, e.g. xsd files for spring various schemas. Also people usually place hibernate mapping files in the same package as the model classes.

MahdeTo
+2  A: 

There is a lot of jar libraries that uses the same practice. I think it is acceptable and comfortable.

Bogdan Gusiev
A: 

I think this is common as long as the files are necessary. The problems arise when people start committing files that are not needed with the source, such as design specs or random text files.

Mr. Will
Don't forget that the Javadoc tool has explicit support for a "doc-files" directory in each package.
erickson
Yeah, I know about those. Those are what I would deem as necessary files.
Mr. Will
+4  A: 

It's very common and even recommended as long as its justifiable. Generally it's justifiable when it's a static resource (DTD+XSLT for proprietary formats, premade scripts etc.) but it's not when the file is something that's likely to be updated by a third party like IP/geographic location database dump.

Esko
Good observation. The key word is indeed "static".
Paul Fisher
A: 

It is surely common, but incredibly lazy and sloppy. My skin crawls when I see it.

Using a tool such as Maven to build your products enables you to easily, and clearly separate code from resources.

Eclipse bundles can be similarly separated.

Nick Veys
Not stupid at all, it has its uses
Mario Ortegón
+3  A: 

I think it gets easier if you think of 'src' as not specifically meaning 'source code'. Think of it as the source of resources that are things needed by your program at compile time and/or runtime.

Things that are a product of compile or build activities should not go here.

Admittedly, like most things, exceptions may apply :)

Update: Personally, I like to break down src further with subdirectories for each resource type underneath it. Others may like that division at a higher level.

Arnold Spence
+7  A: 

The problem with putting non Java (or other languages) files that are closely tied to the code in a different place than the code is knowing where to find the them. It is possible to standardize the locations then theoretically everyone will know where to go and what to do. But I find in practice that does not happen.

Imagine your app still being maintained 5 or 10 years down the road by a team junior - intermediate developers that do not work at the company now and will never talk to anyone who works on your project now. Putting files closely linked with the source in the source package structure could make their lives easier.

I am a big proponent of eliminating as many ambiguities as possible within reason.

Nash0
+1: Very good point. I like information to be near where it is needed :)
Arnold Spence
that hit the spot!
MahdeTo
+1  A: 

In Eclipse it works well for us to have a src folder containing java classes, and a configuration folder (which is blessed as a source folder) containing property files etc. Then they all go in the output folder together and can be found in the classpath while still being in seperate folders inside Eclipse

Thorbjørn Ravn Andersen
I guess thats a good solution too. I usually end up using a filter in a specific view to not look at the resources I am not concerned with at that moment.
Kapsh
+1  A: 

One of the advantages of keeping all the auxiliary files next to the source is that version consistency is maintained between these 3rd party libraries and your source code. If you ever need to go back and debug a specific version, you can pull the entire set of source+config and have it all be the same version.

That being said I'd put them in a $project/config/ directory, or some such, rather than in $project/src/java itself. They're not source, nor java, really, so it's misleading having them in that directory.

When you really get down to it, though, this is an issue of personal style. There's no "Right" answer and you should be talking with those team members and understanding why they made this decision. Using this thread as evidence to support a unilateral decision probably won't go over well. ;)

Alex Feinman