Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using use-dep-version to override a version defined in a parent POM #982

Open
vmckinney-cainc opened this issue Jun 28, 2023 · 1 comment

Comments

@vmckinney-cainc
Copy link

Hi all,

I am wondering if it is possible to use use-dep-version in a child project to override a dependency version defined in a parent.

For example, in a parent POM:

<properties>
  <example.artifact.version>1.2.3</example.artifact.version>
</properties>
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>example.group</groupId>
      <artifactId>example-artifact</artifactId>
      <version>${example.artifact.version}</version>
    </dependency>
  </dependencies>
</dependencyManagement>

Then, in a child that consumes the parent:

mvn versions:use-dep-version -e -Dincludes=example.group:example-artifact -DdepVersion=1.2.4 -DforceVersion=true -DprocessProperties=true -DprocessDependencyManagement=true -DprocessParent=true

I get this error:

[WARNING] Not updating ... in dependencies: version defined in dependencyManagement

Looking at the code:

if (dep.getVersion() == null) {
getLog().warn(String.format(
"Not updating %s:%s in dependencies: version defined " + "in dependencyManagement",
dep.getGroupId(), dep.getArtifactId()));

It seems this happens when the version is null, which I assume is because it's not grabbing the version from the parent. Does the functionality to override versions defined in the parent exist in versions-maven-plugin? If so, is there an obvious issue here? If the functionality exists and you need a minimal reproducible example I can create one -- the actual codebase this fails in is private.

Thank you!

@dasteg
Copy link

dasteg commented Jul 25, 2023

struggling with this as well at the moment. trying to do some "overrides" during a specific phase of development. since dependencies are inherited the use-dep-version goal doesn't do anything.

what works (but quite complicated) is to add a dummy version element in the pom and then replace it with the correct version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants