Assuming you are using common not only in that project but continue to use it in other projects too, you should probably not try to use it as subproject of a multi-project build like that, but instead use it as composite build. Usually you can get the sources artifact for a dependency using an artifact resolution query, but it is to be tried whether this works when having the dependency as included build, never tried that.
Yes, ‘common’ project is used across multiple other projects, that are build indepedently on jenkins. But during local development cycle it is uncomfortable to develop across services and common project, because every change in common must be released (as a snapshot), or deployed to maven local.
So I would like to change build process so when developing locally, with all projects cloned in a single folder, I would like to use project() dependencies and edit sources over all projects at once. Jenkins build should not be affected at all. So I created parent ‘project’ (which is not in git nor jenkins build), used only to “couple” my repos together. In gradle.properties in root project I define variable “local_build=true”, and then in every ‘subproject’ I have following:
Again, you should not do that.
Do not use a project sometimes as part of one build and sometimes as part of another build.
As I said, your use-case is exactly what composite builds are invented for.
You don’t even need to replace binary dependencies (group:module:version) by project dependencies.
You just use a composite build, by including the common build in your project,
either via commandline parameter, or via settings script code includeBuild and the latter could even be inside an if like if property is set or if project exists there, and your binary dependencies are automatically substituted by a subbuild.
Hmm, that looks promising, but no luck with that because original question is still in a place.
‘root’ project:
includeBuild 'commons'
includeBuild 'app'
app reverted to original dependencies (no project()):
implementation("foo:commons:${commonsVersion}")
extractSourcesArtifacts("foo:commons:${commonsVersion}:sources") // this doesn't work in composite build