Sebastien ARBOGAST wrote:
I would like to find a natural solution to share confirguration
files between two modules. [...]
For now, the only solution I've found is to duplicate those files in
src/main/resources for each module.
Brian suggested that I could put those files in a third module to package
them up using assembly, and then retrieve these in both modules that need
it. But it doesn't seem very natural to me.
As a matter of fact, I don't think that this use case is very rare. I
mean,
there are situatiosn where you want to reuse icon graphics or
configuration
files in several modules. And it would be great if we could place those
resources in the parent module and have the submodules inherit resources
from their parent.
What do you think? Would it be feasible? Would it be okay with best
practices promoted by Maven?
I'm used to think of projects as independent build units. More precisely, I
expect the following to work:
- checkout an arbitrary project/module, i.e. not necessarily a whole trunk
- run any build command on this checkout, it should succeed
Now, if I checked out one of your sub-modules how should it inherit its
resources from the parent which is not on my local disk? Maven can retrieve
the POM and the site descriptor from the remote repo but anything else (like
resources) from the parent project is not shared via the repo.
For the above reason, you would need to package the resources up into a JAR
that can be deployed to the repos. Maybe your resources need filtering
before their packaging and now you're quite there what is known as a "jar"
packaging. That is just as Brian suggested, a separate module. And I believe
this is right because sharing POM configuration and sharing resources seem
two different aspects, hence separation of concerns.
Finally note that project inheritance suffers from the same drawback as
class inheritance in ordinary programming: What if you ever needed your
resources in projects that do not inherit from a common parent? Shift it up
the parent chain until you reach a common ancestor and pollute the resources
for all children below? I would rather take the composition approach and
package your resources into an independent project/JAR that other projects
can put on their class path if needed.
Just my two cents,
Benjamin
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]