wstrange / GoogleAuth

Google Authenticator Server side code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please make dependency on httpclient optional

roytmana opened this issue · comments

So that it does not bring in the library and bunch of its dependencies if I do not need the functionality

Hi @roytmana,

I see your point but I'm concerned about the downside of marking those dependencies as optional. Most of the users will want to include this library in their project with a dependency management tool (such as Maven) and they expect the library "will just work". By making it optional, they will have to explicitly add a dependency to httpclient to their project and that will happen after i) noticing a runtime problem or ii) reading the documentation. Considering that this component is used in 1 out of 3 use cases implemented by this library (create credentials, provide QR code with credentials, validate credentials), it seems like a bit of a stretch to me. Finally, the dependency tree of this library is currently this:

--- maven-dependency-plugin:2.8:tree (default-cli) @ googleauth ---
com.warrenstrange:googleauth:jar:1.2.0-SNAPSHOT
+- commons-codec:commons-codec:jar:1.10:compile
\- org.apache.httpcomponents:httpclient:jar:4.4.1:compile
   +- org.apache.httpcomponents:httpcore:jar:4.4.1:compile
   \- commons-logging:commons-logging:jar:1.2:compile

Considering the simplicity of this graph, why don't you just mark httpclient as an exclusion for the time being (read this for Maven)?

If we really wanted to add some optional dependency, as you also suggest in other issue (#47), and at the same time provide a good service to the library users, a more sophisticated way to load a service provider should be provided, to avoid failing with something like a NoClassDefFoundError or a ClassNotFoundException.

I'm closing this issue for the time being. Feel free to reopen it if you want to add more information.

@emcrisostomo
It is what I am doing now.

As I said in another issue it is not about the size of course but about avoiding a single purpose library like yours bringing in dependencies that may conflict with the main application dependencies and in my case it does. As you said it would be nice to implement http client discovery or to keep it simple configuration mechanism to avoid class not found exception

Thank you,
Alex