Maven command for ear project

I have a EAR maven based project that its structure is like below :

------ root
  |
  |--- EAR
        |
        |---- EJB (JAR)
        |
        |---- WEB (WAR)

I want to make a goal for it that first clean all three EAR , EJB , WEB ,module then first install EJB after that install WEB and at the end install EAR because of their dependencies

how I have to do it in just one command line in maven?

here is my pom.xml for root

   <url>http://jboss.org/jbossas</url>
<licenses>
    <license>
        <name>Apache License, Version 2.0</name>
        <distribution>repo</distribution>
        <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
    </license>
</licenses>
<modules>
    <module>ejb</module>
    <module>web</module>
    <module>ear</module>
</modules>

<properties>
<dependencyManagement>
    <dependencies>

        <!-- Define the version of the EJB jar so that we don't need 
            to repeat ourselves in every module -->
        <dependency>
            <groupId>RHAMavenBased</groupId>
            <artifactId>RHAMavenBased-ejb</artifactId>
            <version>${project.version}</version>
            <type>ejb</type>
        </dependency>

        <!-- Define the version of the WAR so that we don't need to repeat 
            ourselves in every module -->
        <dependency>
            <groupId>RHAMavenBased</groupId>
            <artifactId>RHAMavenBased-web</artifactId>
            <version>${project.version}</version>
            <type>war</type>
            <scope>compile</scope>
        </dependency>

Answers


You need the maven multi module project setup. Take a look into this tutorial here. Everything you need is configurable with this

Edit

There is an entry in your parent pom as

    <dependency>
        <groupId>RHAMavenBased</groupId>
        <artifactId>RHAMavenBased-ejb</artifactId>
        <version>${project.version}</version>
        <type>ejb</type>
    </dependency>

I am not mistaken , here ${project.version} is the version of the parent pom that you are building and since it is specified in the parent pom, this dependency trickles down to all sub-modules which is not a good idea in your case, since the EJB project will have dependency on itself ( this is bad design ). Ideally a module should never be dependant on itself. So our first issue is redundant dependency in the modules. Secondly since this is defined in the parent pom and the ${project.version} is being read from the parent pom, we may have version mismatches here or even un-synchronized jars in m2, target and on the build path.


Need Your Help

Visual Studio “Backup Files” folder in my documents

visual-studio

I noticed a long time ago that Visual Studio creates the folder "My Documents/Visual Studio 2010/Backup Files" (2010, 2008 or 2005 as appropriate). Into that folder VS creates a new folder for each

Client Certificate not working from Android - How to debug?

android ssl ssl-certificate bouncycastle spongycastle

I'm trying to implement a Client Certificates communication for an Android App, so far without much success - and it seems that this feature is, if at all possible, very hard. The full flow I'm

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.