简体   繁体   English

Maven “版本”插件排除

[英]Maven "versions" plugin exclusion

I am trying unsuccessfully to exclude packages when displaying/updating versions and I don't get why.我在显示/更新版本时尝试排除包但没有成功,但我不明白为什么。

I have a project:我有一个项目:

<groupId>my.group</groupId>
<artifactId>parent-pom</artifactId>
<packaging>pom</packaging>
<version>1.0</version>

which in the pluginManagement section declares:在 pluginManagement 部分声明:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <excludes>
            <exclude>com.atlassian.confluence:confluence:*</exclude>
        </excludes>
        <generateBackupPoms>false</generateBackupPoms>
        <allowSnapshots>false</allowSnapshots>
    </configuration>
</plugin>

A second plugin is having the above as parent:第二个插件将上面的作为父插件:

<parent>
    <groupId>my.group</groupId>
    <artifactId>parent-pom</artifactId>
    <version>1.0</version>
</parent>

But when I invoke mvn versions:display-dependencies-update , it still reports:但是当我调用mvn versions:display-dependencies-update时,它仍然报告:

com.atlassian.confluence:confluence ..... 5.10.1 -> 6.0.0-viqueen-m001

In case I use a ruleset in the configuration I get error that file is not found (since it is located in the parent pom folder) and cant copy/share cause parent has packaging pom.如果我在配置中使用规则集,我会收到错误消息,即找不到文件(因为它位于父 pom 文件夹中)并且无法复制/共享,因为父文件具有打包的 pom.xml 文件。

I was not able to exclude neither using -DexcludesList nor replacing the <excludes> section with <excludesList> .我无法排除既不使用-DexcludesList也不用 <excludesList> 替换<excludesList> <excludes>部分。 I could only assume that I have a typo in the group:artifact but I have copied over plenty times to avoid such.我只能假设我在 group:artifact 中有一个错字,但我已经复制了很多次以避免这种情况。

Any ideas except having ruleset in the.network?除了在 .network 中设置规则集之外还有什么想法吗?

Edit: As per comment effective-pom is:编辑:根据评论 effective-pom 是:

<pluginManagement>
.
.
.
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>versions-maven-plugin</artifactId>
      <version>2.2</version>
      <configuration>
        <includes>
          <include>my.group</include>
        </includes>
        <excludes>
          <exclude>com.atlassian.confluence:confluence:*</exclude>
        </excludes>
        <generateBackupPoms>false</generateBackupPoms>
        <allowSnapshots>false</allowSnapshots>
      </configuration>
    </plugin>
</pluginManagement>

and versions is not mentioned anywhere else.并且版本在其他任何地方都没有提到。

Problem statement问题陈述

If I understand correctly, you would like to exclude some dependencies from the consideration of the versions:display-dependencies-update Maven goal of the Versions Maven Plugin.如果我理解正确,您想从版本 Maven 插件的versions:display-dependencies-update Maven 目标中排除一些依赖项。

Introduction介绍

Let's consider the following version as the current Maven plugin version:让我们将以下版本视为当前的 Maven 插件版本:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>2.14.2</version>
</plugin>

Possible solution可能的解决方案

Use the corresponding parameters of the Maven goal, which are available since the 2.12.0 version of the Maven plugin:使用Maven目标对应的参数,Maven插件从2.12.0版本开始可用:

  • dependencyExcludes . dependencyExcludes Source . 来源
  • dependencyManagementExcludes . dependencyManagementExcludes Source . 来源

Here is a draft example Maven plugin configuration for your case:这是针对您的案例的草稿示例 Maven 插件配置:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>2.14.2</version>
    <configuration>
        <dependencyManagementExcludes>com.atlassian.confluence:confluence</dependencyManagementExcludes>
        <dependencyExcludes>com.atlassian.confluence:confluence</dependencyExcludes>
        <…>
    </configuration>
</plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM