Multi module dependencies in maven EAR?

2.8k views Asked by At

I'm new to Maven and I'm converting current EAR application into Maven. It is a multi module project (ear, ejb, web, utility).

Some utility modules depend on other utility modules. I don't want Maven to add version number into modules final JARs. So in EAR's POM.XML

I use <bundleFileName> option where I set the name of the final JAR. Problem is that generated MANIFEST.MF file of module which is dependent on this module still uses version number in JAR file name.

Any idea what I'm doing wrong?

Here is excerpt of EAR's pom.xml

<jarModule >
  <groupId>${project.parent.groupId}</groupId>
  <artifactId>batch</artifactId>
  <bundleFileName>batch.jar</bundleFileName>
</jarModule >

Here is excerpt of module's pom.xml

<dependency>
  <groupId>${project.parent.groupId}</groupId>
  <artifactId>batch</artifactId>
  <version>${project.parent.version}</version>
  <type>jar</type>
</dependency>
<build>
<finalName>util</finalName>
<plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>      
        </plugin>
    </plugins>
</build>

The result util's MANIFEST.MF contains batch-1.0.jar But I'd like it to contain batch.jar as mentioned in EAR's pom.xml

1

There are 1 answers

2
Gerard Ribas On

When you release this ear, you will deploy these modules with the same version?

If yes, then you can use it:

For example: project structure:

-EAR
 pom.xml
 --web-module
   pom.xml
 --ejb-module
   pom.xml     

Imagine that web-module has ejb-module dependency, then you can add in web-module project this dependency:

   <dependency>
      <groupId>your.groupId</groupId>
      <artifactId>your.groupId</artifactId>
      <version>${project.version}</version>
   </dependency>

Hope it helps.