-
-
Save ALRubinger/2729351 to your computer and use it in GitHub Desktop.
Is there anything you would do to make this read simpler? Please post in the Gist comments your thoughts! | |
Proposed Code: | |
final File[] shorthand = Maven.resolver().addDependency("G:A:V").addExclusion().groupId("G1").artifactId("A1") | |
.endExclusion().addExclusion("G2:A2").resolve().withTransitivity().as(File.class); | |
...is equivalent to: | |
<dependency> | |
<groupId>G</groupId> | |
<artifactId>A</artifactId> | |
<version>V</version> | |
<exclusions> | |
<exclusion> | |
<groupId>G1</groupId> | |
<artifactId>A1</artifactId> | |
</exclusion> | |
<exclusion> | |
<groupId>G2</groupId> | |
<artifactId>A2</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> |
withTransitivity might be better placed earlier in the example?
ex. Maven.resolver(withTransitivity())
also how about resolve(File.class)? or resolveAs(File.class)
I'm not sure how to avoid the "endExclusion" (or similarly-named construct). In effect here we drill down into a hierarchical level, and need to know somehow that we're going to go back UP from the Exclusion Builder to the Dependency Builder.
WRT your comments on the "withTransitivity" earlier in the example: the current prototype is built in "phases" to follow the grammar:
"I want to (optionally configure from X) and resolve THESE COORDINATES using THIS RESOLUTION STRATEGY, obtaining the result in THIS FORMAT"
...which:
- Allows us to address all use cases with the same flow
- Minimizes the places that users will have to supply arguments (like "resolver(TransitiveResolutionFilter)") thus keeping fluency
I may very well be overlooking ways to make this simpler, but this is the current POC, based on broader discussion:
https://community.jboss.org/thread/198974#733112
Thanks as always Adrian; love having your eyes around.
It may not fit with your POC but can save some typing :
Maven.resolver()
.addDependency("G:A:V").addExclusions("G1:A1", "G2:A2")
.resolve().withTransitivity().as(File.class);
If I have to use endExclusion() and endDependency() I will exclusively use the maven format "G:A:V" to avoid verbosity (and have no use of groupId() and artifactId()).
s/addExclusion/excluding/g no need to have endExclusion provided that excluding switches to a subtype