Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Maven dependency mediation #296

Merged
merged 3 commits into from
Sep 11, 2018
Merged

Conversation

fvgh
Copy link
Member

@fvgh fvgh commented Sep 8, 2018

Currently Spotless uses 2 kinds of dependencies:

  • Resolved dependency list without any transitives (not fully implemented yet)
  • Single ("root") dependencies

The Provisioner interface supports "dependency lists" (currently always resolving transitives).
The previous MavenProvisioner implementation took individually each dependency as a root dependency, resolves it (and its transitives) and puts the JARs into a hash set.

There had been quite an evolution how Maven resolves transitives. Please refer to the Transitive Dependencies documentation for details.

The whole issue is NOT affecting the current formatters (due to the simple dependency structure of current formatters). However, the maven-plugin Provisioner should not interfere with the dependency resolution of Maven to avoid bugs in future evolution of Spotless.

@fvgh
Copy link
Member Author

fvgh commented Sep 8, 2018

@nedtwigg As stated above, currently the problem has no effect on the behaviour. Do you anyhow want an update of the CHANGES.md?

Sorry about the commit message. Will change it when merging.

@fvgh fvgh requested review from lutovich and nedtwigg and removed request for lutovich September 8, 2018 13:47
Copy link
Member

@nedtwigg nedtwigg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a minor suggestion for making the tests a little easier to read, but the substance of the change looks good to me.

Set<File> files = provisioner.provisionWithDependencies("foo", "bar", "baz");

assertThat(files).containsOnly(new File("foo-1"), new File("foo-2"), new File("baz-2"));
private void resolveDependencies() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a little confused about what these tests were doing at first. Maybe rename this to assertFormattingWorks. It would also be a little more robust if it didn't just run, but also asserted that the file on disk was as expected. Maybe assertFormattingWorks(String unformatted, String formatted).

Copy link
Contributor

@lutovich lutovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Made a couple tiny comments.

return mavenCoords -> mavenCoords.stream()
.flatMap(coord -> artifactResolver.resolve(coord).stream())
.collect(toSet());
return mavenCoords -> artifactResolver.resolve(mavenCoords);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe artifactResolver::resolve

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lutovich Sorry, maybe it's just to late... I lost you. Can you explain in detail?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just mean that lambda

return mavenCoords -> artifactResolver.resolve(mavenCoords);

can probably be replaced with method reference

return artifactResolver::resolve;

Then Objects.requireNonNull(artifactResolver); can also be removed because method ref will fail with NPE anyway.

@fvgh fvgh merged commit 4257fee into master Sep 11, 2018
@fvgh fvgh deleted the deterministic_mvn_dependencies branch September 11, 2018 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants