如何将maven插件上传到Nexus存储库?

时间:2012-01-19 11:26:57

标签: plugins maven nexus

我想将自定义maven插件上传到nexus存储库。

我的问题是,当我通过网络IU将我的插件上传到nexus时,普通依赖,maven无法找到它:

  

插件com.huawei:maven-project-version-plugin:1.0或其中一个   无法解析依赖项:无法读取工件描述符   对于com.huawei:maven-project-version-plugin:jar:1.0:找不到   com.mycompany:maven-project-version-plugin:pom:1.0 in   http://localhost:8081/nexus/content/groups/public被缓存在   本地存储库,在更新之前不会重新尝试解析   nexus的间隔已经过去或强制更新 - > [帮助1]

但是当我通过命令行将我的插件安装到maven local repositiry(而不是nexus)时,一切都很好。

那么,安装自定义maven插件和安装“非插件”文物之间的区别是什么?有什么技巧吗?

我的settings.xml:     

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

2 个答案:

答案 0 :(得分:8)

问题解决了。好吧,我不知道怎么做,但今天一切都很好。我认为问题出在Nexus缓存中。我刚删除了我的托管存储库并再次创建它。也许,有一些不太激进的方法,但我不知道它们=)删除工件然后只是“expire cache”在我的情况下没有帮助。

嗯,我的问题的答案:Nexus中的安装插件和非插件工件之间没有任何不同,除了一个。如果选择GAV定义:GAV参数,则必须在组合框“包装”中选择“maven-plugin”。

我认为没有必要一步一步地写指令,这很简单。只需选择您的托管存储库 - &gt; “工件上载”选项卡并填写必填字段。

答案 1 :(得分:4)

另外要补充一点,您还必须上传Maven插件的pom。如果你没有,Nexus会自动生成一个不正确的。即它只是一个由版本,artifactID,包装和groupID组成的基本pom。