views:

18

answers:

1

I have an XSD file that is referenced in three different XML files in different project modules using:

<item-groups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xml_schemas/item_groups.xml.xsd">

I have been trying to figure how to avoid manually copying the XSD into every module that needs it, so I don't have to maintain three files instead of one.

Is there a way in maven that I can have only one version in one of my modules, and at build time it copies it over to the other two?

Thanks!

A: 

Assuming the XSD is packaged in at least one module, it should be possible to achieve what you want with the Maven Dependency plugin and dependency:unpack. The idea would be to bind the goal on generate-resources to unpack the XSD from the module having it (using includes to pick up exactly what you want) and write it where required. See the Unpacking specific artifacts for a full example.

Pascal Thivent
My aim here was just copying the file over, no unpackaging needed being done. I have seen I can just call ant from maven and do it. Thanks for the suggestion though.
blanquish
@blanquish: The above solution is the clean way to do it (to keep modules loosely coupled, to be able to build them independently without checking out the whole project). Now, it you want to break these rules, if coupling your modules together is not a concern, then you can use relative paths and so on to copy a file from one module to another (the resource plugin can do that), sure. But that's not the right way to do it.
Pascal Thivent