0

我正在尝试创建自定义检查样式。已经在 sonatype 上有SNAPSHOT但是我试图对其进行测试的测试项目无法拉动依赖。错误是

[INFO] Building TestProject 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-checkstyle-plugin:2.10:checkstyle (default-cli) @ TestProject ---
Downloading: http://repository.apache.org/snapshots/com/novoda/novoda-checkstyle-checks/1.0-SNAPSHOT/maven-metadata.xml
Downloading: http://repository.apache.org/snapshots/com/novoda/novoda-checkstyle-checks/1.0-SNAPSHOT/novoda-checkstyle-checks-1.0-SNAPSHOT.pom
[WARNING] The POM for com.novoda:novoda-checkstyle-checks:jar:1.0-SNAPSHOT is missing, no dependency information available
Downloading: http://repository.apache.org/snapshots/com/novoda/novoda-checkstyle-checks/1.0-SNAPSHOT/novoda-checkstyle-checks-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.993s
[INFO] Finished at: Thu Aug 08 16:37:42 BST 2013
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.10:checkstyle (default-cli) on project TestProject: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.10:checkstyle failed: Plugin org.apache.maven.plugins:maven-checkstyle-plugin:2.10 or one of its dependencies could not be resolved: Could not find artifact com.novoda:novoda-checkstyle-checks:jar:1.0-SNAPSHOT in apache.snapshots (http://repository.apache.org/snapshots) -> [Help 1]

这是项目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>TestProject</groupId>
  <artifactId>TestProject</artifactId>
  <version>0.0.1</version>

  <properties>
    <checkstyle.config.location>properties/checkstyle-configuration.xml</checkstyle.config.location>
  </properties>

  <repositories>
    <repository>
      <id>sonatype-nexus-snapshots</id>
      <name>Sonatype Nexus Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.10</version>
        <dependencies>
          <dependency>
            <groupId>com.novoda</groupId>
            <artifactId>novoda-checkstyle-checks</artifactId>
            <version>1.0-SNAPSHOT</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

</project>

知道为什么没有下载依赖插件吗?

4

2 回答 2

2

解决方法很简单。因为它是我试图获取的插件,所以我需要使用它pluginRepositories而不是repositories

  <pluginRepositories>
    <pluginRepository>
      <id>sonatype-nexus-snapshots</id>
      <name>Sonatype Nexus Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
于 2013-08-09T14:36:18.613 回答
0

您可以看到 maven 正在错误的 repo 中寻找快照http://repository.apache.org/snapshots/
您的工件在https://oss.sonatype.org/content/repositories/snapshots

您用来运行的 pom 不是定义 sonatype 的 pom,<repository>或者它正在被覆盖。检查你运行 maven 的文件夹中的有效 pom 并找到定义,你可能会发现它是 apache.org 而不是 sonatype 的

或者,通常不建议<repository>在您的 pom 中使用它,因为它会使无法访问特殊 repo 的其他人无法使用工件,请查看这篇文章我更喜欢在settings.xml中配置自定义 repo(sonatype 快照)

于 2013-08-08T20:21:46.590 回答