当我正在运行versions:display-dependency-updates
时,它会显示我所有依赖项的最新beta /里程碑版本。我更喜欢使用"发布"包。
versions:use-latest-releases
谈及"替换"最新发布的版本。但是,我更喜欢手动更新版本。
我可以运行版本插件来报告最新的"发布"我的依赖项和插件的版本?
我指的是"类型" mvnrepository.org
上列出的包裹答案 0 :(得分:5)
两步
将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
版本规则也将stay for future releases插件。
答案 1 :(得分:2)
也许我误解了一件事但是如果我使用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从4.11到4.12等等。此外,问题是你的依赖项的版本是什么样的?