How to package nested maven modules for full product suite build

296 views Asked by At

At our company, we typically build an number of flex client applications, for numerous different clients. Each Flex application typically loads at runtime, a differing variety of standalone Flex Module swfs as well.

I'm trying to Mavenise the project, but am confused as how to progress. The directory structure is pretty much flat, but I can't figure in my head how to tier the poms in order to be able to build from any position in the hierarchy.

The structure might be as follows:

Client1 - pom.xml
-App1 - pom.xml
-App2 - pom.xml
-App3 - pom.xml
-Module1 - pom.xml
-Module2 - pom.xml

Client2 - pom.xml
-App1 - pom.xml
-App2 - pom.xml
-Module1 - pom.xml
-module2 - pom.xml
-Module3 - pom.xml

The problems is that, if I want to build say Client2/App1 and all of it's dependent modules (ie. Client2/Module1 & Client2/Module2). Of course I can declare:

<modules>
   <module>Module1</module>
   <module>Module2</module>
</modules>

inside of the Client2/App1/pom.xml, specifying the package as 'pom', but this doesn't allow to actually compile the swf for Client2/App1 itself.

I could just package Client2/App1 as swf and have it build the Client2/App1.swf itself, and declare in Client2/pom.xml:

<modules>
   <module>App1</module>
   <module>Module1</module>
   <module>Module2</module>
</modules>

but would like the option of building Client2/App2 independently as well, or any other application for that matter.

1) Could I setup different modules declarations using profiles perhaps in order to facilitate arbitrary client builds?

2) Is there another way to nest poms, with the aggregator level pom also executing some compilation goal as well?

3) I've seen you can add additional poms using a name other than pom at the same level to facilitate this, but it seems I can't include those poms in the declaration.

Any help/ideas appreciated.

1

There are 1 answers

0
Christofer Dutz On

Usually you would have a pom.xml defining the modules (In case of Client1 this would be App1, App2, App3, Module1 and Module2) If you tell maven to build Client1 this would automatically build all of the client modules. In general maven doesn't support you building one module and have maven automatically build all modules it depends on. You could however create individual profiles in Client1-pom each one selecting a different subset:

<profiles>
  <profile>
    <id>BuildApp1</id>
    <modules>
        <module>App1</module>
        <module>Module1</module>
        <module>Module2</module>
    </modules>
  </profile>
  <profile>
    <id>BuildApp2</id>
    <modules>
        <module>App2</module>
        <module>Module1</module>
        <module>Module2</module>
    </modules>
  </profile>
</profiles>

So you would tell maven to activate the profile "BuildApp1" or "BuildApp2" and it would build a different subset of modules.