maven 如何仅显示发布版本的依赖项更新

pwuypxnk  于 2023-05-22  发布在  Maven
关注(0)|答案(2)|浏览(146)

当我运行versions:display-dependency-updates时,它将显示我的依赖项的所有最新beta / milestone版本。我更喜欢使用“释放”包。
versions:use-latest-releases谈到了用最新的发布版本“替换”。但是,我更喜欢手动更新版本。
我可以运行版本插件来给予我的依赖项和插件的最新“发布”版本吗?
我指的是mvnrepository.org上列出的软件包的“类型

rxztt3cl

rxztt3cl1#

两步
rulesUri添加到插件配置

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <rulesUri>file:///${project.basedir}/rules.xml</rulesUri>
    </configuration>
    <executions>
        <execution>
        <phase>compile</phase>
        <goals>
            <goal>display-dependency-updates</goal>
            <goal>display-plugin-updates</goal>
        </goals>
        </execution>
    </executions>
</plugin>

rules.xml文件添加到项目根目录。

<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" comparisonMethod="maven" 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">
    <ignoreVersions>
        <!-- Ignore Alpha's, Beta's, release candidates and milestones -->
        <ignoreVersion type="regex">(?i).*Alpha(?:-?\d+)?</ignoreVersion>
        <ignoreVersion type="regex">(?i).*a(?:-?\d+)?</ignoreVersion>
        <ignoreVersion type="regex">(?i).*Beta(?:-?\d+)?</ignoreVersion>
        <ignoreVersion type="regex">(?i).*-B(?:-?\d+)?</ignoreVersion>
        <ignoreVersion type="regex">(?i).*RC(?:-?\d+)?</ignoreVersion>
        <ignoreVersion type="regex">(?i).*CR(?:-?\d+)?</ignoreVersion>
        <ignoreVersion type="regex">(?i).*M(?:-?\d+)?</ignoreVersion>
    </ignoreVersions>
    <rules>
    </rules>
</ruleset>

正则表达式过滤掉不稳定的版本。您还可以针对特定依赖项的规则,请参阅:
http://blog.xebia.com/keeping-dependencies-up-to-date-in-maven/
https://gist.github.com/seahrh/b13f4f3d618ad7c817038e0bc124ef29
版本规则也将保留为插件的未来版本。

6qqygrtg

6qqygrtg2#

也许我误解了一件事,但如果我使用mvn versions:display-dependency-updates,它会产生这样的输出:

~/ws-git/test-project (two-module)$ mvn versions:display-dependency-updates
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Project : Parent
[INFO] Project : Mod-A
[INFO] Project : Mod-B
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project : Parent 0.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:display-dependency-updates (default-cli) @ project-parent ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.beust:jcommander .................................... 1.35 -> 1.55
[INFO]   com.google.guava:guava ................................ 16.0.1 -> 19.0
[INFO]   junit:junit ............................................. 4.11 -> 4.12
[INFO]   log4j:log4j ............................. 1.2.16 -> 1.2.17-atlassian-1
[INFO]   org.apache.logging.log4j:log4j-api ...................... 2.1 -> 2.6.1
[INFO]   org.apache.logging.log4j:log4j-core ..................... 2.1 -> 2.6.1
[INFO]   org.mockito:mockito-core ........................ 1.9.5 -> 2.0.78-beta
[INFO]   org.testng:testng .................................... 6.8.8 -> 6.9.12
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project : Mod-A 0.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:display-dependency-updates (default-cli) @ mod-a ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.beust:jcommander .................................... 1.35 -> 1.55
[INFO]   com.google.guava:guava ................................ 16.0.1 -> 19.0
[INFO]   junit:junit ............................................. 4.11 -> 4.12
[INFO]   log4j:log4j ............................. 1.2.16 -> 1.2.17-atlassian-1
[INFO]   org.apache.logging.log4j:log4j-api ...................... 2.1 -> 2.6.1
[INFO]   org.apache.logging.log4j:log4j-core ..................... 2.1 -> 2.6.1
[INFO]   org.mockito:mockito-core ........................ 1.9.5 -> 2.0.78-beta
[INFO]   org.testng:testng .................................... 6.8.8 -> 6.9.12
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Project : Mod-B 0.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:display-dependency-updates (default-cli) @ mod-b ---
[INFO] The following dependencies in Dependency Management have newer versions:
[INFO]   com.beust:jcommander .................................... 1.35 -> 1.55
[INFO]   com.google.guava:guava ................................ 16.0.1 -> 19.0
[INFO]   junit:junit ............................................. 4.11 -> 4.12
[INFO]   log4j:log4j ............................. 1.2.16 -> 1.2.17-atlassian-1
[INFO]   org.apache.logging.log4j:log4j-api ...................... 2.1 -> 2.6.1
[INFO]   org.apache.logging.log4j:log4j-core ..................... 2.1 -> 2.6.1
[INFO]   org.mockito:mockito-core ........................ 1.9.5 -> 2.0.78-beta
[INFO]   org.testng:testng .................................... 6.8.8 -> 6.9.12
[INFO]
[INFO] No dependencies in Dependencies have newer versions.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Project : Parent ................................... SUCCESS [  0.791 s]
[INFO] Project : Mod-A .................................... SUCCESS [  0.046 s]
[INFO] Project : Mod-B .................................... SUCCESS [  0.019 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.671 s
[INFO] Finished at: 2016-07-03T22:17:02+02:00
[INFO] Final Memory: 20M/439M
[INFO] ------------------------------------------------------------------------

在这里你可以看到像junit:junit from 4.11 to 4.12等。此外,问题是你的依赖关系的版本看起来如何等等。?

相关问题