SRKprakash
SRKprakash

Reputation: 113

Maven Error:Artifact is not a dependency of the project

   [ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-
    plugin:2.6:generate-application-xml (default-generate-application-xml) 
    on project itaras-ear: Artifact[war:org.apache.maven.plugins:maven-war-
    plugin] is not a dependency of the project. 

First I built a WAR file for my application. Now I am in the process of building my EAR file which is supposed to have WAR as dependency.

I have run ITARAS-EAR module with m2e plugin when I got the above mentioned error message.

module WAR's pom.xml is below.

  <parent>
   <groupId>itaras</groupId>
   <artifactId>itaras</artifactId>
   <version>1.0-SNAPSHOT</version>
  </parent>
<groupId>itaras-war</groupId>
 <artifactId>itaras-war</artifactId>
 <packaging>war</packaging>
  <build>
<plugins>
  <plugin>            
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
   <configuration>
       <webXml>src\main\webapp\WEB-INF\web.xml</webXml>        
      </configuration>
     </plugin>
     </plugins>
       </build>
    </project>

Module EAR's pom.xml is here.

  <parent>
  <groupId>itaras</groupId>
  <artifactId>itaras</artifactId>
  <version>1.0-SNAPSHOT</version>
  </parent>
 <artifactId>itaras-ear</artifactId>
 <packaging>ear</packaging>
  <dependencies>
    <dependency>
        <groupId>itaras-war</groupId>
        <artifactId>itaras-war</artifactId>

        <type>war</type>
        <version>${project.version}</version>
    </dependency>

   </dependencies>
     <build>
     <plugins>
      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-ear-plugin</artifactId>
        <version>2.6</version>
        <configuration>
              <defaultLibBundleDir>lib</defaultLibBundleDir>
            <applicationXML>src/main/application/META-
        INF/application.xml</applicationXML>
         </configuration>
    </plugin>
     </plugins>
    </build>
    <groupId>itaras-ear</groupId>
     </project>

Thanks in advance. Do Correct me if I had gone fundamentally wrong :)

Upvotes: 5

Views: 9618

Answers (1)

Essex Boy
Essex Boy

Reputation: 7968

Your war project has 2 groupIds

<parent>
   <groupId>itaras</groupId>
   <artifactId>itaras</artifactId>
   <version>1.0-SNAPSHOT</version>
  </parent>
*** <groupId>itaras-war</groupId> ****
<artifactId>itaras-war</artifactId>
<packaging>war</packaging>

Remove the groupId and allow it to pick it's groupId from the parent. Only specify the artifactId, version and groupId from the parent.

Then your dependency to the war in your ear project is:

<dependencies>
  <dependency>
      <groupId>itaras</groupId>
      <artifactId>itaras-war</artifactId>
      <type>war</type>
      <version>${project.version}</version>
  </dependency>
</dependencies>

Upvotes: 6

Related Questions