Changing the version of a subproject dependency

I have a multi-module kotlin project, where each module is versioned separately.
Let’s say we have the following structure:

  • root_project (does not produce artifacts, current version 1.2.0)
    – foo_module (produces artifacts, current version 1.2.0)
    – bar_module (produces artifacts, current version 1.0.0)

In foo I have a dependency on bar via: api(project(":bar"))

When I build a pom file or a gradle metadata file for the publication of foo, I can see it declares version of bar as 1.2.0, which does not exists.

Is there any way to override the version for the project dependency?
Or is my only option is to declare it as non-project dependency, e.g. api("xxx:foo:$version")?

Is the version of bar properly declared for the project, or do you change it on the publication? If the latter, try setting it properly on the project instead.

Thanks for the reply.
I’ve found it was an issue on my side and it’s now resolved.

The version is set via settings plugin, but I forgot that I also tried to modify it in the build file, which resulted in unexpected behavior.

1 Like