Friday, June 27, 2008

Maven does NOT support SOCKS for HTTP

I have a internal repository which can only be accessed through SOCKS, so I thought, if I set up a <proxy> in settings.xml with SOCKS_5 as its protocol, it shall work -- to download artifacts from the repository through the proxy. By the way, the documentation is not clear about what you should specify for the protocol. I used SOCKS_5 because ProxyInfo sounded right.

After a few attempts, I realized from the error logs that Maven did not go through the SOCKS proxy I defined, it basically skipped it. I hooked my IDE to the process to for some debugging to realize that Wagon (the transport abstraction of Maven) chose to use LightweightHttpWagon to download the artifacts and would only know how to deal with HTTP based proxy. Wagon chose it by looking up for Plexus component with the role-hint of http, damn.

I believe I could create a local repository by mounting the remote end using FUSE/sshfs. I didn't anyway, I made HTTPd to allow external connections to the repository with basic auth enabled (the server uses Archiva anyway). That's quick and at least I wouldn't have to guess why scp or file wasn't working later.

Playing with Maven is a pain, sometimes.. or most of the time if it doesn't work.

P/S: If you can really make Maven to work with HTTP+SOCKS, let me know and tell me that I'm wrong.

- yc

2 comments:

Brian Fox said...

Take a look at the Nexus FAQ, which shows how to enable the JDK to use SOCKS. You can take those options and add them to your MAVEN_OPTS variable and Maven should thus use socks. Oh, and check out Nexus while you're there ;-)

http://nexus.sonatype.org/faq.html

Y said...

Ah, something from Sonatype. Alright, I will take a look into it in a short while.

Thanks a lot!

yc