:
Skip Navigation
Resources Blog Maven Does Not Dictate Structure. Maven Promotes It!

Maven Does Not Dictate Structure. Maven Promotes It!

This is my response a comment on TSS about the structure in Maven projects. We recommend a structure we don't dictate one ...

The directory structure used by a Maven project has never been fixed. There are defaults, yes, but they can all be overridden. I have had many clients over the years that have had existing structures that needed to be preserved for various policy reasons, or projects that had lives spanning many branches into the past where changing the directory structure would have made merging a nightmare. The defaults are easy to change at a project, or organizational level. That the structure is fixed in Maven is a myth.

Many organizations choose to start new projects using the standard structure and/or migrate to the standard where possible as standard Maven documentation, training, and idioms then apply. Maven's defaults were chosen to allow for growth but are, in fact, as arbitrary as the defaults in any other system. The advantage is that our defaults are used by a few hundred thousand people and there are undeniable benefits in a collective understanding of a project structure. I'm not trying to say this alone mitigates any of the implementation defects in Maven (of which no one is more acutely aware then myself) or that a default structure alone is a good reason to use Maven. But it lends itself toward building a level of social capital (a measure of how well groups can work together) because there is some common structure from which to work from and communicate. Maven does not dictate a structure, contrary to popular opinion, but we definitely promote one.

You have used your same Ant build files since 2002 which works for you. If you deliver using this tool set who can argue with that. But I have seen the argument many times over and it goes something like "my structure is pretty simple because I stick to the basics and it does what I need." This is perfectly fine in isolated cases but try to onboard new developers, find resources for your build and release team, attract developers to your open source project, reach a standard in your department, or your organization, integrate with disparate parts of your organization, incorporate third party libraries, integrate open source and you will rapidly find N pivot points against which you must learn something different to make the overall system work. This is simply an untenable proposition for a community of people trying to together efficiently.

Maven has many flaws, but it is very usable by a large number of groups. Maven is also not static. Not many people know that .NET and C toolchains have been created for Maven, or that with a few new implementations of internal components that Maven can build OSGi components directly from manifest information (look Mom, no POM!), or that you can write Maven plugins in Groovy, Ruby, or Ant script. Many of these things are unknown because the Maven project has admittedly been terrible at documenting these attributes and features. This is a failure at the Maven community level that we are trying address.

Ultimately it's your decision as a user. If Maven doesn't work for you don't use it. But Maven was not meant to cater to personal biases, it was meant to work for groups and as such compromises need to be made in order to use Maven effectively. Maven is not for anyone in particular, it was intended for a large number of users who have made a conscious decision to work in more or less in the same way to achieve results in what they are making, not in how they make it.

Picture of Jason van Zyl

Written by Jason van Zyl

Jason is a co-founder and the former CTO of Sonatype.