gradle-consistent-versions
gradle-consistent-versions copied to clipboard
Any way to make some of the subprojects excluded from consistent-versions
What happened?
Hi, Sorry for the question. I'm not sure if this is the right place to ask a question, but I need your suggestions.
We're working on a Java project with consistent-versions enabled, we have a requirement to use two versions of same artifact for two subprojects separately. Say subproject A requires version 2.x of artifact foo, subproject B requires version 3.x of artifact foo. The reason for such choice is that 3.x foo is not so mature and 2.x is a long term support version, so we want to support both 2.x and 3.x of foo in one build, maintaining two branches separately is burden for us to keep sync.
What did you want to happen?
So I would like to know if there's a way to make this plugin only work for some specified subprojects.
Sorry for my question, and looking forward to your reply.
Hey @jerryshao, thanks for using GCV!
Internally we've had this situation come up as well once or twice, but we usually advise to make a new repo when encountering this situation.
This is because we have a lot of repos, and there is massive value in being able to quickly spot exactly what a repo depends on, based on their versions.lock, so having the versions.lock reflect 'part' of a repo would be confusing.
Another solution we haven't tried ourselves but which will probably work fine, if you must use a single repo, is to have two builds (each applying GCV separately) and connect them together as a composite build. For instance, one build B could have all of your current projects including "subproject B", and another build A could have the "subproject A" where it can safely depend only on version 2.x of artifact foo. Note that this will work as long as your inter-project dependencies from build A -> build B don't pull in foo 3.x as a transitive dependency.