简体   繁体   中英

Multi module dependencies in maven EAR?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM