Leos Literak
Leos Literak

Reputation: 9406

intermodule dependencies in maven

I want to build maven project having EJB module and WEB module, where EJB is needed in WEB module.

parent pom.xml

<modelVersion>4.0.0</modelVersion>
<groupId>cz.literak.oauth</groupId>
<artifactId>OAuthLogin</artifactId>
<packaging>pom</packaging>

<version>1.0-SNAPSHOT</version>
<modules>
    <module>OAuthLogin-web</module>
    <module>OAuthLogin-ejb</module>
</modules>
<name>OAuthLogin JEE Skeleton</name>
<url>http://www.literak.cz/OAuthLogin/</url>

EJB pom.xml

<parent>
    <artifactId>OAuthLogin</artifactId>
    <groupId>cz.literak.oauth</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>OAuthLoginEJB</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ejb</packaging>
<name>OAuthLoginEJB Beans</name>

WEB pom.xml

<parent>
    <artifactId>OAuthLogin</artifactId>
    <groupId>cz.literak.oauth</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>OAuthLoginWEB</artifactId>
<packaging>war</packaging>
<name>OAuthLogin Webapp</name>

<dependencies>
    <dependency>
        <groupId>cz.literak.oauth</groupId>
        <artifactId>OAuthLogin-ejb</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
</dependencies>

Intellij Idea tells me that version is unknown. When I run mvn clean install in parent module, it fails with:

[ERROR] Failed to execute goal on project OAuthLoginWEB: Could not resolve dependencies for project cz.literak.oauth:OAuthLoginWEB:war:1.0-SNAPSHOT: Could not find artifact cz.literak.oauth:OAuthLogin-ejb:jar:1.0-SNAPSHOT -> [Help 1]

Where is the issue? I browsed similar questions without luck. Thanks.

Upvotes: 0

Views: 1654

Answers (1)

khmarbaise
khmarbaise

Reputation: 97547

You have defined the artifactId of your ejb module like this:

<artifactId>OAuthLoginEJB</artifactId>

but not

<artifactId>OAuthLogin-ejb</artifactId>

BUT YOUR DEPENDENCY is like this:

<dependencies>
    <dependency>
        <groupId>cz.literak.oauth</groupId>
        <artifactId>OAuthLogin-ejb</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>ejb</type>
    </dependency>
</dependencies>

Upvotes: 2

Related Questions