如何将 Maven 插件上传到 Nexus 存储库?
我想将我的自定义 Maven 插件上传到 Nexus 存储库。
我的问题是,当我像普通依赖项一样通过 web 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 中 http://localhost:8081/nexus/content/groups/public 已缓存在 本地存储库,更新之前不会重新尝试解析 联结间隔已过或强制更新 -> [帮助1]
但是当我通过命令行将插件安装到maven本地存储库(不是nexus)时,一切都很好。
那么,安装自定义 Maven 插件和安装“非插件”工件有什么区别?有什么技巧吗?
我的设置.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>
I want to upload my custom maven plugin to nexus repository.
My problem is that when I upload my plugin to nexus via web IU like ordinary dependency, maven can't find it:
Plugin com.huawei:maven-project-version-plugin:1.0 or one of its
dependencies could not be resolved: Failed to read artifact descriptor
for com.huawei:maven-project-version-plugin:jar:1.0: Failure to find
com.mycompany:maven-project-version-plugin:pom:1.0 in
http://localhost:8081/nexus/content/groups/public was cached in the
local repository, resolution will not be reattempted until the update
interval of nexus has elapsed or updates are forced -> [Help 1]
But when I am install my plugin to maven local repositiry (not nexus) via command line all is fine.
So, what is the difference between installing custom maven plugin and installing "non plugin" artefacts? Are there any tricks?
My 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题解决了。好吧,我不知道怎么办,但今天一切都是工作。我认为问题出在 Nexus 缓存中。我刚刚删除了托管存储库并再次创建了它。也许,还有不太激进的方法,但我不知道它们 =) 删除工件,然后只是“过期缓存”对我的情况没有帮助。
好吧,我的问题的答案:Nexus 中的安装插件和非插件工件之间没有任何区别,除了一个。如果选择 GAV Definition: GAV 参数,则必须在组合框“Packaging”中选择“maven-plugin”。
我觉得没必要写一步一步的指令,很简单。只需选择您的托管存储库 ->工件上传选项卡并填写必填字段。
The problem was solved. Well, I don't know how, but today all is work. I think the problem was in Nexus cache. I just deleted my hosted repository and created it again. Perhaps, there are less radical methods, but I don't know them =) Delete artifact and then just "expire cache" not help in my case.
Well, the answer of my question: There is no any different between installation plugin and non plugin artifact in Nexus, except one. If you select GAV Definition: GAV parameters, you must select "maven-plugin" in combobox "Packaging".
I think there is no need to write step by step instruction, it is very simple. Just select your hosted repository -> Artifact Upload tab and fill required fields.
另外要补充的是,您还必须上传 Maven 插件的 pom。如果您不这样做,Nexus 将自动生成一个不正确的文件。即它只是一个基本的 pom,由版本、artifactID、packaging 和 groupID 组成。
Also to add that you must also upload the pom of your Maven plugin. If you don't Nexus will auto generate one which is not correct. i.e. it will just be a basic pom consisting of version, artifactID, packaging, and groupID.