Clay Banks
Clay Banks

Reputation: 4581

Importing Wrong Dependency Versions

I'm using Maven with Eclipse - my POM contains the dependencies:

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
</dependency>
<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-plugin-api</artifactId>
    <version>3.2.3</version>
</dependency>

In my build path I see a red "x" on maven-plugin-api-2.0.6.jar. I also see other jars that are using version 2.0.6 (maven-core, maven-project, maven-etc.) which seem to compile fine - I know importing the correct jar version would solve the problem, but why is eclipse trying to use an older version of maven on my project?

Upvotes: 0

Views: 275

Answers (1)

khmarbaise
khmarbaise

Reputation: 97437

First a maven-plugin should never be used as a dependency. It should be configured as a plugin and NOT as a dependency see the following:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.6</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

Upvotes: 1

Related Questions