views:

257

answers:

1

I've been looking at profiles in maven for selecting different sets of dependencies. This is fine when you want to build say a debug build differently from a release build. My problem is that I want to do a fair bit more than this. For my application (Mobile Java app where J2ME is just one target among many) there may be a large number of possible combinations of variations on a build.

Using some made-up command line syntax to illustrate what I'd like to see, I'd imagine typing in something like

mvn -Pmidp,debug,local-resources

What Maven does in this case is to build three different builds. What I want to do is use those three (Or more, or less) switches to affect just one build. So I'd get a MIDP-targetting debug build with 'local resources' (Whatever that might mean to me - I'm sure you can imagine better examples).

The only way I can think of doing this would be to have lots and lots of profiles which becomes quite problematic. In my example, I'd have

-Pmidp-debug-localresources
-Pmidp-release-localresources
-Pmidp-debug-remoteresources
-Pmidp-release-remoteresources
...

Each with its own frustratingly similar set of dependencies and build tag.

I'm not sure I've explained my problem well enough, but I can re-write the question to clarify it if comments are left.

UPDATE:

The question isn't actually valid since I'd made a false assumption about the way maven works.

-Pmidp,debug,local-resources

does not do 3 builds. It in fact enables those 3 profiles on one build, which was ironically what I was looking for in the first place.

+2  A: 

The Maven way is to create a lot of artifacts with less complexity. I'd say your best bet is to abstract the common parts of each build into a separate artifact, then create a project for each build that defines the build specific parts. This will leave you with a lot of projects, but each will be much simpler.

Steve Moyer
I have that, but it's the selection of a specific part within a superpart that has me stumped, particularly when I want to choose between a large set of possible small parts, each doing some small thing, and each possibly a variant of another.
izb