I am trying to update the version in a maven pom.xml
that depends on a parent pom.xml
.
I have /pom.xml
that looks like this
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.burnian.parent</groupId>
<artifactId>parent</artifactId>
<version>14.0.0</version>
<packaging>pom</packaging>
<!-- Plugins & other modules -->
</project>
And the child /child/pom.xml
that looks like this (and is not a module in parent's pom).
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>me.burnian.parent</groupId>
<artifactId>parent</artifactId>
<version>13.0.0</version>
<!-- I've tried <relativePath>../pom.xml</relativePath> with no success -->
</parent>
<artifactId>child</artifactId>
<packaging>jar</packaging>
<!-- Again other stuff I think irrelevant here -->
</project>
As you can see, child's pom.xml
refers to version 13.0.0
of parent, which is now version 14.0.0
.
My goal is to update the version in the parent
section to the correct version, using CLI only.
I've tried this sequence of commands which works properly and updates the parent version in the child's pom.xml
:
mvn versions:set -DnewVersion=14.0.0 # To update parent version
mvn clean install # To build parent module with new version
mvn -f child/pom.xml versions:update-parent -DparentVersion="[14.0.0]"
But whenever I try to implement it with -Dmaven.repo.local
, the same process fails.
mvn -Dmaven.repo.local=./.m2/ versions:set -DnewVersion=14.0.0
mvn -Dmaven.repo.local=./.m2/ clean install
mvn -Dmaven.repo.local=./.m2/ -f child/pom.xml versions:update-parent -DparentVersion="[14.0.0]"
The third command fails with Could not find artifact me.burnian.parent:parent:pom:13.0.0 in Proxied-Maven
. I've tried adding -DforceUpdate=true
but since I am not with a RELEASE
or LATEST
version (and can't use one), it has no effect.
Is there something I am missing? I've checked and there is indeed me.burnian.parent
with a 14.0.0 folder in the ./.m2
repository, but the last command seems not to find it.
Thanks for your help
<packaging>jar
is the default. You don't have to declare it explicitely.<groupId>me.burnian.parent
is confusing since there's also achild
in it. I'd call the group justme.burnian
, containingparent
andchild
then. - Gerold Broser