Skip to content

Instantly share code, notes, and snippets.

@ALRubinger
Created May 19, 2012 05:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ALRubinger/2729351 to your computer and use it in GitHub Desktop.
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>
@jclouds
Copy link

jclouds commented May 19, 2012

s/addExclusion/excluding/g no need to have endExclusion provided that excluding switches to a subtype

@jclouds
Copy link

jclouds commented May 19, 2012

withTransitivity might be better placed earlier in the example?

ex. Maven.resolver(withTransitivity())

also how about resolve(File.class)? or resolveAs(File.class)

@ALRubinger
Copy link
Author

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.

@ALRubinger
Copy link
Author

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.

@ggrossetie
Copy link

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()).

@ALRubinger
Copy link
Author

ALRubinger commented May 19, 2012 via email

@jclouds
Copy link

jclouds commented May 19, 2012 via email

@jclouds
Copy link

jclouds commented May 19, 2012 via email

@jclouds
Copy link

jclouds commented May 19, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment