jbang
jbang copied to clipboard
Downloading dependencies under proxy
Hi,
On my work laptop, JBang cannot download dependencies when under corporate proxy. Interestingly, JDK is downloaded without a problem. I guess it is because JDK and dependencies are downloaded through two different channels (JBang proper vs Maven?) where one reads http_* environment variables and the other doesn't. Is there an environment variable I can set to fix this for apparently Maven, that is used under the hood for downloading dependencies? MAVEN_OPTS and JAVA_TOOL_OPTS did not work, and I prefer not to create a settings.xml file in the Maven home.
Many thanks
does it work when you set it via settings.xml? if that does not work then no amount of env var to change it will fix it.
users reports JAVA_TOOL_OPTS works here https://github.com/jbangdev/jbang/discussions/671 or system proxies https://github.com/jbangdev/jbang/issues/547#issuecomment-734154630
jbang's proxy support looks broken.
As org.apache.maven.wagon.providers.http.LightweightHttpsWagon.openConnection() is actually used for making the HTTP connection (via sun.net HttpClient), it ignores system proxy configuration.
Instead, it looks for the proxy configuration within the org.eclipse.aether.repository.RemoteRepository.RemoteRepository
but jbang fails to set a proxy in the Repository's builder.
I can confirm that the two solutions mentioned before do not work.
Thanks @patric-r for the feedback, that's very useful! You're not able to provide a fix by any chance as well, are you? :wink:
Btw, JBang doesn't deal directly with the Aether API but uses Shrinkwrap, so we have to figure out how to set a proxy for that.
@quintesse Yes, I noticed that as well. IMHO dev.jbang.dependencies.DependencyUtil.resolveDependenciesViaAether() looks like a good start for dealing with the proxy.
For sensible defaults, it make sense to either use the system proxy or maven defaults (e.g. .m2/settings.xml). BTW, is there a reason why jbang uses a customized version of shrinkwrap? This feels a little bit "unusual" (not to say hacky...).
looks like a good start for dealing with the proxy.
Indeed, the problem is how. There doesn't seem to be anything in the API that deals with Proxies (at least the last time I looked).
is there a reason why jbang uses a customized version of shrinkwrap?
The explanation for that can be found in this PR: https://github.com/jbangdev/jbang/pull/673
I also just doubly verified that setting the proxy in settings.xml makes the mvn command use it but it does not affect the behavior of jbang.
same issue here
Which issue? Settings.xml not working or?
Any issues with proxies should go away once we decide to switch to MIMA.
Any issues with proxies should go away once we decide to switch to MIMA.
What is MIMA? :)
MIMA is what is coming in via this PR https://github.com/jbangdev/jbang/pull/1604
It is where jbang will be able to use more recent setup of maven's artifact resolver.
Yeah, but later I realized that will only fix the proxy issues for artifact resolving/downloading, not for the other http requests we make. So that's still something we should definitely fix in our code.