To build a Java EE application with Maven, one can use the following configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
<ejbModule>
[..]
</ejbModule>
<jarModule>
[..]
</jarModule>
</modules>
</configuration>
</plugin>
I understand that the web module is packaged differently from other modules, that is, for example, being located at the root of the ear and having packed it's own dependencies to WEB-INF/lib.
But what about jar and ejb modules? How are they different from each other?
And what is the difference of defining a jar as a normal dependency and/or defining it as a jarModule or earModule?
Beeing more precise, what is the difference between the following setups:
1. ejb module defined as ejbModule
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
<ejbModule>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
</dependencies>
2. ejb module defined as dependency
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<depdendency>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
3. ejb/jar defined as jarModule
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
<jarModule>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
4. ejb/jar defined as dependency
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<modules>
<webModule>
[..]
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<depdendency>
<groupId>org.example</groupId>
<artifactId>helloworld-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>