Is there any way to get the requested.version from a componentSelection rule?


(Eric Isakson) #1

I’m trying to implement a resolution strategy where I need some information about how the dependency version was expressed during the component selection phase. Partly I’m implementing semantic version rules and some of this on the component selection side is related to other custom artifact properties.

During eachDependency, I take my custom version selection syntax and convert it to a range expression. So something like:

foo:bar:%1.2.3-m.1

ends up calling details.useVersion(’[1.2.3-m.1,2.0.0-0)’)

Then later during component selection, I want to do some additional pruning based on other details about the specific candidate that I didn’t have during the eachDependency phase but I need the "%1.2.3-m.1’ version selector in order to know what rules to apply. For example only accept prerelease versions if the normal version is 1.2.3 and some other things that I can’t determine from the version number that we store as custom properties in the POM.

I’ve thought about creating a map keyed on the requested group and name with the version as a value during eachDependency and then looking them up in componentSelection but that felt like it had a lot of opportunities to go wrong. Would that be a safe operation? Anything I should watch out for? Any other way to achieve this?