Created
May 19, 2012 05:24
-
-
Save ALRubinger/2729351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
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()).
Agreed Guillaume; the code you've got there _is_ currently supported as well.
It actually makes me wonder what exactly the use case is for having
the builder (for groupId(), artifactId(), etc.)...
Sounds icky perhaps underneath, but couldn't you do this by having
addExclusion return a subtype of DependencyBuilder once minimum parameters
are caught?
I probably need to show the code, but hard to hack in android as yet ;)
…On May 18, 2012 10:41 PM, "Andrew Lee Rubinger" < ***@***.***> wrote:
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.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2729351
Gotcha. I see what you mean. The phases are succinct
…On May 18, 2012 10:45 PM, "Andrew Lee Rubinger" < ***@***.***> wrote:
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:
1) Allows us to address all use cases with the same flow
2) 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.
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2729351
+1 for stringified coordinate syntax.
…On May 19, 2012 5:21 AM, "Andrew Lee Rubinger" < ***@***.***> wrote:
Agreed Guillaume; the code you've got there _is_ currently supported as
well.
It actually makes me wonder what exactly the use case is for having
the builder (for groupId(), artifactId(), etc.)...
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2729351
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
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.