
本文介绍了如何阻止Nexus中的特定Maven工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们通过本地Nexus存储库使用Maven.不幸的是,在查询新版本时,我们得到了一些误报:
commons-collections:commons-collections ............ 3.2.1 -> 20040616
org.hibernate:hibernate-entitymanager ..... 4.1.9.Final -> 4.3.0.Beta1
第一个是较旧的版本,但命名方案不正确.第二个实际上只是一个Beta版本(我们通常不提供这些版本,但有些似乎会漏掉).现在的问题是:这些版本不是真正存在于我们的存储库中,而是来自我们的Nexus所指代的存储库之一吗?
我尝试了 routing ,但是要么我弄错了它,要么它不能阻止特定的版本,只能阻止所有版本的完整工件.我已经在文档中看到了采购,但是它看起来非常复杂,我也不敢尝试.
解决方案
您可以在项目的POM(或公司的母公司)中配置versions-maven-plugin
,以使用规则文件告知插件要忽略哪些版本.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- some location that makes sense for your company/project -->
<rulesUri>http://host.company.com/maven-config/maven-version2-rules.xml</rulesUri>
</configuration>
</plugin>
示例规则文件如下所示.我的忽略了commons-logging插件的"99.0-does-not-exist存在"版本.
<ruleset xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0
http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
<rules>
<rule groupId="commons-logging" artifactId="commons-logging">
<ignoreVersions>
<ignoreVersion>99.0-does-not-exist</ignoreVersion>
</ignoreVersions>
</rule>
</rules>
</ruleset>
您可以添加配置以全局全局忽略其他版本,而不是像我在此处所做的那样逐个工件,并且也可以使用正则表达式.有关更多信息,请参见插件文档.
We use Maven through a local Nexus repository. Unfortunately, when querying for new versions, we get several false positives:
commons-collections:commons-collections ............ 3.2.1 -> 20040616
org.hibernate:hibernate-entitymanager ..... 4.1.9.Final -> 4.3.0.Beta1
The first is a version that is ancient but with an incorrect naming scheme. The second is actually only a beta version (we don’t usually get these, but some seem to slip through). Now the question is: How can these versions, which are not really on our repository but come from one of the repositories our Nexus refers to, be excluded?
I have tried routing, but either I got it wrong or it cannot block specific versions, only the complete artifacts with all its versions. I have seen procurement in the documentation, but it seems very complicated and I did not dare trying.
解决方案
You may configure the versions-maven-plugin
in your project's POM (or a corporate parent somewhere) to use a rules file telling the plugin which versions to ignore.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<!-- some location that makes sense for your company/project -->
<rulesUri>http://host.company.com/maven-config/maven-version2-rules.xml</rulesUri>
</configuration>
</plugin>
An example rules file looks like the below. Mine ignores the "99.0-does-not-exist" version of the commons-logging plugin.
<ruleset xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0
http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
<rules>
<rule groupId="commons-logging" artifactId="commons-logging">
<ignoreVersions>
<ignoreVersion>99.0-does-not-exist</ignoreVersion>
</ignoreVersions>
</rule>
</rules>
</ruleset>
You may add configuration to ignore other versions globally, not per-artifact as I did here, and regular expressions may be used as well. More information is available in the plugin documentation.
这篇关于如何阻止Nexus中的特定Maven工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!