Since the child modules I depended on were the same version as the parent, I changed
${project.version}
to
${project.parent.version}
and using the version configuration in the edit, the errors went away.
Question
I'm using Maven 3.1.1 and trying to use the Maven release plugin to release a child module of a multi-module project. The parent module was released and this child module is not in the parent's child module list. In my child module pom.xml file, I have
<parent>
<artifactId>subco</artifactId>
<groupId>org.mainco.subco</groupId>
<version>52.0.0-SNAPSHOT</version>
</parent>
<name>myproject</name>
<url>http://maven.apache.org</url>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mainco.subco</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencyManagement>
<dependencies>
...
<dependency>
<groupId>org.mainco.subco</groupId>
<artifactId>core</artifactId>
</dependency>
However, when I run the below
mvn -B -DdevelopmentVersion=52.0.1-SNAPSHOT -DreleaseVersion=52.0.0 -Dusername=***** -Dtag=myproject-52.0.0 -DskipTests -P prod -Dresume=false -DdryRun=true -DallowTimestampedSnapshots=true org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare
I get the errors
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare (default-cli) on project myproject: Can't release project due to non released dependencies :
[ERROR] org.mainco.subco:core:jar:52.0.0-SNAPSHOT:compile
...
[ERROR] org.mainco.subco:subco:pom:52.0.0-SNAPSHOT
I'm not able to change any properties in the parent pom.xml file … is there anything I can do in the child module to get the above command to run successfully? I like using "${project.version}" because I don't have to hard-code versions in my pom. Also note that I'm using "-DallowTimestampedSnapshots=true" which is getting ignored.
Edit:
Even adding a separate version element to the pom, like so
<parent>
<artifactId>subco</artifactId>
<groupId>org.mainco.subco</groupId>
<version>52.0.0</version>
</parent>
<name>myproject</name>
<url>http://maven.apache.org</url>
<version>52.0.0-SNAPSHOT</version>
results in the same errors as above.
Solution
Since the child modules I depended on were the same version as the parent, I changed
${project.version}
to
${project.parent.version}
and using the version configuration in the edit, the errors went away.
OTHER TIPS
Use the released version of the parent.
<parent>
<artifactId>subco</artifactId>
<groupId>org.mainco.subco</groupId>
<version>52.0.0</version>
</parent>
You'll also need to specify the version of the current project; since it isn't released with the parent, it needs to have its own version element.
For those coming from googling the error:
Check if you have any dependency in your pom.xml
that contains the word SNAPSHOT
.
Or if your project's version has a SNAPSHOT
and one or more of your dependencies use the project version:
<version>${project.version}</version>
Reason ist that maven simply does not allow SNAPSHOT dependencies in mvn release:prepare.
You can also use the option -DignoreSnapshots=true
but use it with caution and only if you know what you are doing, otherwise you end up releasing SNAPSHOT dependencies!!
After setting -DignoreSnapshots=true
, mvn release:prepare
was fine with them and I can see in Log:
17:34:54 [INFO] Ignoring SNAPSHOT depenedencies and plugins ...