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

dependencies with optional dependencies are not properly resolved. #125

Closed
vrozov opened this issue Mar 15, 2016 · 7 comments
Closed

dependencies with optional dependencies are not properly resolved. #125

vrozov opened this issue Mar 15, 2016 · 7 comments

Comments

@vrozov
Copy link

vrozov commented Mar 15, 2016

for example dependency on com.ning:async-http-client:1.7.x leads to an error due to it's optional dependencies on com.google.guava:guava.

@siom79
Copy link
Owner

siom79 commented Mar 17, 2016

Optional dependencies are according to the documentation only normal dependencies in the pom where they are defined. In your example guava is only a normal dependency within async-http-client. Projects that depend on async-http-client do not resolve this optional dependency. Hence it should be correct that the dependency on guava gets not resolved if it is declared to be optional for async-http-client.

What error do you get?

@vrozov
Copy link
Author

vrozov commented Mar 17, 2016

adding async-http-client as a dependency to dependencies section of japicmp maven plugin results in async-http-client dependency not being resolved error.

@siom79
Copy link
Owner

siom79 commented Mar 17, 2016

According to my understanding of optional dependencies guava should be added to the dependency section of your project.

@vrozov
Copy link
Author

vrozov commented Mar 18, 2016

No, it should not. It should work exactly the same as if async-http-client was added as a dependency to the project pom.

@siom79
Copy link
Owner

siom79 commented Mar 19, 2016

But async-http-client declares guava as optional. Hence modules using async-http-client should not import it.

The idea behind optional dependencies is that if you implement a facade for let's say different database projects, than you declare the dependencies in your facade project on the different database vendors as optionals. Clients to your facade project do only add the dependency they acutally need (e.g. H2 and not MySql, Oracle, etc.) and don't import all optional ones.

But I could change japicmp that one can configure to also include optional dependencies. But then all optional dependencies are pulled in. But what if you don't have access to a specific optional dependency because it resides on a repository you don't have access to?

And when I make it configurable that you can choose which optional depencendies to pull in, then it is the same as if you would add the optional dependency to your project.

@vrozov
Copy link
Author

vrozov commented Mar 20, 2016

This is exactly how optional dependency should work. Problem is that when I include a dependency with optional dependencies into <dependencies> section of japicmp the entire build fails.

siom79 added a commit that referenced this issue Mar 20, 2016
…le for optional dependency could not be resolved
@siom79
Copy link
Owner

siom79 commented Mar 20, 2016

OK. Thanks for the details regarding dependencies section of japicmp itself.

The dependencies listed here are resolved by japicmp and it checks that all dependencies could be resolved properly. Otherwise japicmp threw an exception. As I configured the ArtifactResolutionRequest to skip optional dependencies, I thought it would not return them. But as I have now seen it will return the Artfact object but with getFile() returning nothing. This led the code throw an exception because not all dependencies could be resolved properly.

I have now introduced a check if the Artfact was optional that in this case I don't expect getFile() to return something useful.

@siom79 siom79 closed this as completed Mar 20, 2016
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

No branches or pull requests

2 participants