How can you add a externalmoduledependency with an...
# community-support
p
How can you add a externalmoduledependency with an older version of the same gav (with a higher version) of the project? I want to fetch an older (binary) release of the project, but it will be always be replaced/substituted by the project. I tried strict versions/rejecting the new version, dependency, attributes and dependencySubstitution.
t
Reminds me of https://github.com/gradle/gradle/issues/11625, that was closed as not planned, and Ben Manes found a workaround (downloading the JAR at build time); but that wasn't exactly the same issue I believe (the project dependency is still replacing the external module, and the problem was that it wasn't compiled yet, so Ben only added the released JAR as a dependency)
p
Thanks, yes sounds like the same problem but I don't know if I can the same workaround.
m
Maybe
useGlobalSubstitutionRules
(doc) ? This is specifically for included build but maybe it also works for the same build? Sounds like a stretch but worth a try?
p
Thanks, but that also did not work.
m
Welps, sorry then. Thanks for trying it out!
I guess you could also do something in the likes of:
Copy code
project.group = "thisisagroupidtoconfusegradle"
And use the "good" one only in publishing:
Copy code
publishing {
  publications.create("foo", MavenPublication::class.java) {
    pom {
      groupId = "goodGroupIdHere"
      // ...
    }
  }
}
This is ugly and breaking including your build but this part can be workarounded using custom resolution rules I believe
v
It only uses the project if the version is newer unless you have set
preferProjectModules()
, so actually setting the version to something lower than what you want to get from external would be better as then you do not use manual substitution rules even if you include the build somewhere else
👍 1
I'm not sure how it is with a detached configuration, maybe that could also work if you do not need it in a "normal" configuration, but I didn't try that yet which one resolves then.