2
votes

i want to create three projects. One of them is parent project and the other two will be modules.

On this site http://maven.apache.org/plugins/maven-eclipse-plugin/reactor.html it is explained how to do. It says that the packaging type by parent should be pom. In my case it is not a good option. I want to use an existing project as parent project and create two additional modules.

Is it possible to define my existing project (war) as parent?

2

2 Answers

3
votes

I suspect the only way to use a parent project is to define the parent packaging as pom. It clearly says so on the maven site, like you also pointed out. I really can't see what you want to achieve with your scenario because it seems to me that way its impossible for the two modules to exist as dependencies for the war...

I strongly recommend you to create the parent pom add the other three modules under it (the two additional modules and the war/webapp module). Through separate parent you also have better control over the module build order, dependency management, global properties etc.

1
votes

Parent

<groupId>com.biz</groupId>
<artifactId>app-parent</artifactId>
<packaging>war</packaging>
<version>0.1-SNAPSHOT</version>
<name>app-parent</name>
<dependencies>
//...
</dependencies>

Child

<groupId>com.biz</groupId>
<artifactId>app-child1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>app-child1</name>

<dependencies>
    <dependency>
        <groupId>com.biz</groupId>
        <artifactId>app-parent</artifactId>
        <version>0.1-SNAPSHOT</version>
        <type>war</type>
    </dependency>
</dependencies>

I've got issues with autodeploy in eclipse with tomcat plugin, but mvn install (first parent, then child) works Ok.