checkstyle-maven-plugin依赖冲突

时间:2013-05-30 13:22:39

标签: maven checkstyle

我想使用maven-checkstyle-plugin,但每当我执行它时,我都会收到此错误:

% mvn checkstyle:checkstyle                                                                      :(
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building checkstyle-extension 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-checkstyle-plugin:2.10:checkstyle (default-cli) @ checkstyle-extension ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.843s
[INFO] Finished at: Thu May 30 15:10:32 CEST 2013
[INFO] Final Memory: 12M/159M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.10:checkstyle (default-cli) 
on project checkstyle-extension: Execution default-cli of goal 
org.apache.maven.plugins:maven-checkstyle-plugin:2.10:checkstyle failed: 
An API incompatibility was encountered while executing 
org.apache.maven.plugins:maven-checkstyle-plugin:2.10:checkstyle: 
java.lang.NoSuchMethodError: com.google.common.collect.Multimaps.newHashMultimap()Lcom/google/common/collect/HashMultimap;
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-checkstyle-plugin:2.10
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/antoras/.m2/repository/org/apache/maven/plugins/maven-checkstyle-plugin/2.10/maven-checkstyle-plugin-2.10.jar
[ERROR] urls[1] = file:/home/antoras/.m2/repository/edu/kit/checkstyle/checkstyle-extension/1.0-SNAPSHOT/checkstyle-extension-1.0-SNAPSHOT.jar
[ERROR] urls[2] = file:/home/antoras/.m2/repository/checkstyle/checkstyle/5.0/checkstyle-5.0.jar
[ERROR] urls[3] = file:/home/antoras/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar
[ERROR] urls[4] = file:/home/antoras/.m2/repository/com/google/guava/guava/14.0/guava-14.0.jar
[ERROR] urls[5] = file:/home/antoras/.m2/repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar
[ERROR] urls[6] = file:/home/antoras/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[7] = file:/home/antoras/.m2/repository/org/apache/maven/reporting/maven-reporting-api/3.0/maven-reporting-api-3.0.jar
[ERROR] urls[8] = file:/home/antoras/.m2/repository/org/apache/maven/reporting/maven-reporting-impl/2.2/maven-reporting-impl-2.2.jar
[ERROR] urls[9] = file:/home/antoras/.m2/repository/org/apache/maven/doxia/doxia-core/1.2/doxia-core-1.2.jar
[ERROR] urls[10] = file:/home/antoras/.m2/repository/xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar
[ERROR] urls[11] = file:/home/antoras/.m2/repository/xml-apis/xml-apis/1.3.04/xml-apis-1.3.04.jar
[ERROR] urls[12] = file:/home/antoras/.m2/repository/org/apache/httpcomponents/httpclient/4.0.2/httpclient-4.0.2.jar
[ERROR] urls[13] = file:/home/antoras/.m2/repository/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar
[ERROR] urls[14] = file:/home/antoras/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar
[ERROR] urls[15] = file:/home/antoras/.m2/repository/commons-validator/commons-validator/1.3.1/commons-validator-1.3.1.jar
[ERROR] urls[16] = file:/home/antoras/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
[ERROR] urls[17] = file:/home/antoras/.m2/repository/commons-digester/commons-digester/1.6/commons-digester-1.6.jar
[ERROR] urls[18] = file:/home/antoras/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1.3/doxia-sink-api-1.1.3.jar
[ERROR] urls[19] = file:/home/antoras/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1.3/doxia-logging-api-1.1.3.jar
[ERROR] urls[20] = file:/home/antoras/.m2/repository/org/apache/maven/doxia/doxia-decoration-model/1.1.3/doxia-decoration-model-1.1.3.jar
[ERROR] urls[21] = file:/home/antoras/.m2/repository/org/apache/maven/doxia/doxia-site-renderer/1.1.3/doxia-site-renderer-1.1.3.jar
[ERROR] urls[22] = file:/home/antoras/.m2/repository/org/apache/maven/doxia/doxia-module-xhtml/1.1.3/doxia-module-xhtml-1.1.3.jar
[ERROR] urls[23] = file:/home/antoras/.m2/repository/org/apache/maven/doxia/doxia-module-fml/1.1.3/doxia-module-fml-1.1.3.jar
[ERROR] urls[24] = file:/home/antoras/.m2/repository/org/codehaus/plexus/plexus-i18n/1.0-beta-7/plexus-i18n-1.0-beta-7.jar
[ERROR] urls[25] = file:/home/antoras/.m2/repository/org/apache/maven/shared/maven-doxia-tools/1.2.1/maven-doxia-tools-1.2.1.jar
[ERROR] urls[26] = file:/home/antoras/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar
[ERROR] urls[27] = file:/home/antoras/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[28] = file:/home/antoras/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[29] = file:/home/antoras/.m2/repository/org/codehaus/plexus/plexus-resources/1.0-alpha-7/plexus-resources-1.0-alpha-7.jar
[ERROR] urls[30] = file:/home/antoras/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar
[ERROR] urls[31] = file:/home/antoras/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.13/plexus-interpolation-1.13.jar
[ERROR] urls[32] = file:/home/antoras/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.8/plexus-velocity-1.1.8.jar
[ERROR] urls[33] = file:/home/antoras/.m2/repository/com/puppycrawl/tools/checkstyle/5.6/checkstyle-5.6.jar
[ERROR] urls[34] = file:/home/antoras/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar
[ERROR] urls[35] = file:/home/antoras/.m2/repository/commons-beanutils/commons-beanutils-core/1.8.3/commons-beanutils-core-1.8.3.jar
[ERROR] urls[36] = file:/home/antoras/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
[ERROR] urls[37] = file:/home/antoras/.m2/repository/org/apache/velocity/velocity/1.5/velocity-1.5.jar
[ERROR] urls[38] = file:/home/antoras/.m2/repository/commons-lang/commons-lang/2.1/commons-lang-2.1.jar
[ERROR] urls[39] = file:/home/antoras/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
[ERROR] urls[40] = file:/home/antoras/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

guavagoogle-collections之间似乎存在依赖性冲突,但我不知道如何解决它。

这是我的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>edu.kit.checkstyle</groupId>
  <artifactId>checkstyle-extension</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>checkstyle-extension</name>
  <url>http://kit.edu</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>checkstyle</groupId>
      <artifactId>checkstyle</artifactId>
      <version>5.0</version>
    </dependency>
  </dependencies>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.10</version>
        <configuration>
          <configLocation>checkstyle.xml</configLocation>
          <packageNamesLocation>edu/kit/checkstyle/checks/packagenames.xml</packageNamesLocation>
        </configuration>
      </plugin>
    </plugins>
  </reporting>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.10</version>
        <configuration>
          <enableRulesSummary>false</enableRulesSummary>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>edu.kit.checkstyle</groupId>
            <artifactId>checkstyle-extension</artifactId>
            <version>1.0-SNAPSHOT</version>
          </dependency>
          <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>14.0</version>
            <exclusions>
              <exclusion>
                <groupId>com.google.collections</groupId>
                <artifactId>google-collections</artifactId>
              </exclusion>
            </exclusions>
          </dependency>
          <!--dependency>
            <groupId>com.google.collections</groupId>
            <artifactId>google-collections</artifactId>
            <version>1.0</version>
          </dependency-->

        </dependencies>
      </plugin>
    </plugins>
  </build>

</project>

我尝试从google-collections中排除guava依赖项,并直接指定google-collections依赖项但不起作用。

看起来我有类似this question中的类似问题。但是那里的解决方案对我不起作用(明确添加google-collections依赖)。

关于如何解决这个问题的任何想法?

1 个答案:

答案 0 :(得分:1)

经过长时间的搜索,我终于找到了自己的问题。存在不兼容的依赖项:

  

[错误]网址[2] =档案:/home/antoras/.m2/repository/checkstyle/checkstyle/5.0/checkstyle-5.0.jar

  

[错误]网址[33] =档案:/home/antoras/.m2/repository/com/puppycrawl/tools/checkstyle/5.6/checkstyle-5.6.jar

第一个版本5.0,第二版版本5.6。从5.0移动到5.6后,一切正常。