1
votes

After looking at various suggestions, I still can't seem to have any successful maven strategy for ear files.

I have this structure:

parent pom.xml: ...

  <modules>
        <module>MyProject-ear</module>
        <module>MyProject-ejb</module>
        <module>MyProject-war</module>
  </modules>

(ejb/war/ear have this as parent)

I'm using maven-war-plugin / maven-ejb-plugin / maven-ear-plugin.

EAR module has the ejb/war projects as dependencies.

Now, if I want to build my ear, I need to build the war first. If I don't, it's just not the latest version.

Is there a better way?

EDIT: FYI, opened a netbeans bug to have a working solution to run my project just by clicking "run": http://netbeans.org/bugzilla/show_bug.cgi?id=218807

1
the order of the modules is not correct. place the war module on top so it is build prior to the ear module which should be the last one in the list. If you then build your parent the ear file will be correct. If you only build the ear module you will have issues with not up-to-date .war dependencieswemu
@wemu The order of the modules is only relevant if there are no other way to determine the build order. In his example the ear has a dependency on the war which will result in a correct build order. maven.apache.org/guides/mini/guide-multiple-modules.htmlmaba
I dont think so. The ear module will see a dependency and try to resolve it in the local repository, then in the remotes. The dependency does not tell where the module is build. If there is a CI build that makes sure the .war is up-to-date that wont be an issue but I would not reverse the module build order. I've seen this behavior too often to believe what the link states is entirely true. Better be safe than sorry :)wemu
@wemu looks quite plausible, I'll check thatymajoros
Doesn't seem to help here. Maybe it will fix something in my automated builds however (I think that I once had to build twice before it worked).ymajoros

1 Answers

0
votes

That looks fine. I use the same layout myself.

When building you just have to be positioned at the top pom and run mvn install. You don't have to go down the hierarchy and build the war first.