maven-plugin:maven只下载pom,而不是内部仓库的jar文件

时间:2012-05-14 10:46:44

标签: maven-2 maven-plugin

我对maven很陌生,我在使用我在公司的内部(archiva)存储库中编写和发布的插件时遇到了一些麻烦。

我可以看到,在回购的网址上,插件的构建和发布似乎有效:

  • 创建了repo目录
  • 目录包含:
    • pom,pom.sh1,pom.md5文件
    • jar,jar.sh1,jar.md5文件

在我的插件的pom.xml文件中,我引用了内部仓库的url:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.myorg</groupId>
  <artifactId>myorg-build-info-plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <version>1.0.0</version>
  <name>myorg-build-info-plugin Maven Mojo</name>
  <url>labserver.myorg-domain.com:8380/archiva/repository/internal</url>
....

十,我在另一个pom.xml中引用了这个插件:

<plugin>
          <groupId>com.morg</groupId>
          <artifactId>myorg-build-info-plugin</artifactId>
          <version>1.0.0</version>
...

我确实在同一个pom.xml中提供了内部仓库:

<repositories>
        <repository>
            <id>myorg-repo</id>
            <name>Repository for Myorg Artifacts</name>
            <url>http://labserver.myorg-domain.com:8380/archiva/repository/internal</url>
            <layout>default</layout>
        </repository>

最后如果我对该pom文件执行maven clean操作(执行 mvn clean -e ),我收到以下错误:

+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building com.myorg.projectname
[INFO]    task-segment: [clean]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/com/myorg/myorg-build-info-plugin/1.0.0/myorg-build-info-plugin-1.0.0.pom
[INFO] Unable to find resource 'com.myorg:myorg-build-info-plugin:pom:1.0.0' in repository central (http://repo1.maven.org/maven2)
Downloading: http://labserver.myorg-domain.com:8380/archiva/repository/internal/com/myorg/myorg-build-info-plugin/1.0.0/myorg-build-info-plugin-1.0.0.pom
1K downloaded  (myorg-build-info-plugin-1.0.0.pom)
Downloading: http://repo1.maven.org/maven2/com/myorg/myorg-build-info-plugin/1.0.0/myorg-build-info-plugin-1.0.0.jar
[INFO] Unable to find resource 'com.myorg:myorg-build-info-plugin:maven-plugin:1.0.0' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command: 
...

现在我可以看到:

我希望扫描所有的回购,特别是文件中声明的内部回购。

显然事实并非如此。

所以如果有人知道为什么会发生这种情况,我真的很感激一些帮助!

TIA,

PS:我正在使用maven 2.2.1 for debian with JDK 1.6.029

1 个答案:

答案 0 :(得分:3)

我建议的第一件事是使用像ArchivaArtifctoryNexus这样的存储库管理器。此外,我建议您阅读以下文章:http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/。 除了之前的版本,您需要定义一个pluginRepository区域,如下所示:

 <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>