You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Ryan Moquin <fr...@gmail.com> on 2008/10/29 21:39:45 UTC

Question about project packaging

Hello,

I'm hoping that I'm not thinking in the wrong track with this question or
that there is an obvious answer to it that I should have been able to find
(I'm not completely sure I'm searching for it with the correct terms).
Anyhow, I have a need for being able to reuse a maven2 project to build
multiple artifacts, each of which are the same with the exception of a
single xml file (and POSSIBLY the addition of a custom jar file).  Otherwise
they are exactly identical.  Currently I am creating a new maven2 project
for each of those artifacts and then customizing that one file in the
project directory.  This is starting to become extremely tedious now that I
have quite a few different custom xml files, even though it's straight
forward.  Anytime I need to modifiy that structure, I must then go and
modify in every single one of the identical projects for whatever change I
made.

So, this scenario seems to lend to a solution based on using the Maven2
Assembly plugin, or using a profile to refer to a different location for the
xml file that changes.  I'm not exactly sure which is best though.  In case
this isn't making sense, let me give an example scenario and why I'm not
sure which is best.  Let's say I have 2 projects, projectA and projectB:

- ProjectA
     - pom.xml
     - src/main/resources/custom.xml
     - src/test/java/some.GlobalTestsForCustomXML.java

- ProjectB
     - pom.xml
     - src/main/resources/custom.xml
     - src/test/java/some.GlobalTestsForCustomXML.java

The custom.xml in both project projects are a similar config file, that is
configured differently.  There is also some unit tests that sanity check the
custom.xml configuration to make sure it's sane.  The artifacts from both
projects, get deployed as two separate entities on a deployment server.  The
custom.xml customizes the deployment on the server.

So, I want to be able to build all my deployable artifacts using a single
project, which we'll call ProjectX.  I want to use maven2 to build ProjectX
the same number of times as different custom.xml files that I have.  I
thought about using a profile to specify a location to get each custom.xml
file and execute the build for it, but I'm not sure how you would make it
build the project once for each profile you specify other than using a batch
file.  I could build the project once and then use the maven2 assembly
plugin to extract the artifact and insert a different artifact, but this
could still lead to maintenance issues since I would need an assembly xml
file for each one and it seems to me to be overkill just to insert one
file.  This would also cause me to have problems with my global unit tests
running against each custom.xml file.

I'd really like to just create a new custom.xml and be able to have it build
into an artifact with ProjectX with as minimal effort as possible.

Has anyone done anything similar or have any suggestions on how to
accomplish what I am describing while minimizing the maintence of a large
amount of duplicate projects?

Thanks!
Ryan