首页 > 解决方案 > Versions Maven Plugin update-parent 检查在线 maven

问题描述

我有 2 个 maven 项目,父母和孩子,都有 0.0.1-SNAPSHOT。

父母的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.tmn</groupId>
  <artifactId>parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <name>parent</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

</project>

孩子的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.tmn</groupId>
  <artifactId>child</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <parent>
      <groupId>com.tmn</groupId>
      <artifactId>parent</artifactId>
      <version>0.0.1-SNAPSHOT</version>
  </parent>

  <name>child</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

</project>

我将父 pom 的版本更新为某个发布版本,比如 1.0.0 并mvn clean install在我的父级上做了。所以,我的 maven 本地 repo 包含已发布的 pom。现在,我想更新 parent.version 和我的孩子 pom 的版本。我跑

mvn versions:update-parent -DparentVersion=1.0.0 -DgenerateBackupPoms=false -Dmaven.repo.local=/path/to/repo

我希望它盲目地将 parent.version 更新为我在命令中提供的 parentversion。但是我收到了这个警告并且它没有更新。

artifact com.tmn:parent: checking for updates 
[WARNING] Not updating version: could not resolve any versions

这里记录了一个类似的问题,但我不明白这个问题的解决方案:https ://github.com/mojohaus/versions-maven-plugin/issues/121

标签: mavenmaven-pluginversions-maven-plugin

解决方案


推荐阅读