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

Issue resolving dependencies through a proxy #139

Closed
imartinbe opened this issue May 8, 2014 · 9 comments
Closed

Issue resolving dependencies through a proxy #139

imartinbe opened this issue May 8, 2014 · 9 comments
Labels

Comments

@imartinbe
Copy link

Plugin : 1.3.0, Netbeans 7.4 & 8.0, gradle 1.11
I am busy setting my project to download dependencies from maven repositories.
I have the following setting in my build.gradle :

repositories {
        maven {
            url "http://repo.jfrog.org/artifactory/repo1-cache"            
        }
        maven {
           url "http://repo.jfrog.org/artifactory/jcenter-cache"            
        }
}

I have also set the proxy configuration in _%GRADLE_USER_HOME%\gradle.properties_ file :

systemProp.http.proxyUser=myUser
systemProp.http.proxyPassword=mySecret
systemProp.http.proxyHost=proxy.intranet
systemProp.http.proxyPort=8080
systemProp.http.nonProxyHosts=*.intranet|localhost
systemProp.https.proxyUser=myUser
systemProp.https.proxyPassword=mySecret
systemProp.https.proxyHost=proxy.intranet
systemProp.https.proxyPort=8080
systemProp.https.nonProxyHosts=*.intranet|localhost

I have some dependencies set in the project :

compile group: 'junit', name: 'junit', version: '4.10'

When I launch a _gradle clean build_ or _reload project_ or any other task in Netbeans project, it hangs for a while and then I get this stacktrace in the notifications :

Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.api.internal.externalresource.transport.http.HttpRequestException: Could not HEAD 'http://repo.jfrog.org/artifactory/repo1-cache/junit/junit/4.10/junit-4.10.jar'.
...
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: java.net.SocketException: Malformed reply from SOCKS server

If I launch _gradle clean build_ on command line (from git bash), it downloads correctly the dependencies.
My GRADLE_USER_HOME environment variable is set the same way as in the plugin options.

Download http://repo.jfrog.org/artifactory/repo1-cache/junit/junit/4.10/junit-4.10.jar

I wonder if the netbeans plugin is taking the correct proxy settings (from gradle.properties)

@kelemen
Copy link
Owner

kelemen commented May 8, 2014

The NetBeans plugin is oblivious to those properties, it is Gradle who uses them. However, my experience is that you have to adjust the proxy settings in NetBeans in cases like this (I don't know what exactly is going on under the hood).

@imartinbe
Copy link
Author

It uses to work before, with plugin version 1.2.6. I was receiving the downloading messages in the output window. Now, since it has been moved to notification window, it stucks to the task Loading Subproject... (Resolve dependencies 'RootProject:Subproject1') on the status bar, and no message comes in the output for several minutes before I get an error with the stacktrace in the notification window...

@imartinbe
Copy link
Author

Is there a place where we can find the intermediate output log from the reload project?

@kelemen
Copy link
Owner

kelemen commented May 9, 2014

Probably the best place to look is the logs of Gradle (as the plugin does not provide - and never did - any info about proxy servers). The logs should be in the ~/.gradle/daemon/<Gradle version> directory.

@imartinbe
Copy link
Author

I have not found any clue which could help me in the logs. It seems that the problems is in the gradle tooling API. I have raised a problem in gradle forum (http://forums.gradle.org/gradle/topics/problem_loading_dependencies_through_a_proxy_using_the_gradle_tooling_api)

@imartinbe
Copy link
Author

Hi Attila,
I have removed all references to maven repositories through proxies : I now connect on an internal maven repository proxying itself on mavencentral. => So, it should not connect to proxy anymore.
But it continues to fail with same SOCKS malformed error.
Investigating further, I have set the --debug mode and saw that :

  • the proxy server is still invoked, even if not needed
  • as you said in your first answer, the Netbeans proxy settings are used, not gradle.properties ones.
    I have then removed the proxy settings in Netbeans and then the dependencies are loaded correctly.
    I am surprised that the Netbeans "No Proxy Hosts" settings are not taken into account in this case... and what is surprising too is that it is trying to use the SOCKS settings by default :
  • if I set the proxy settings for http and https and leave empty socks settings, I receive an error
Received status code 407 from server: Proxy Authentication Required
  • if I set the socks settings to the same proxy as http/https, I receive the error
Malformed reply from SOCKS server

The proxy I use seems not accepting SOCKS...

Anyway, this seems to be a Netbeans issue...

@kelemen
Copy link
Owner

kelemen commented May 22, 2014

I don't think it is really a NetBeans issue. I believe that both NetBeans and Gradle's Tooling API tries to do its best and some information simply cannot be communicated by the two parties being oblivous to each other. The plugin has absolutely no way to say what proxy is to be used. I can see, that Radim answered your question on the Gradle forum and given that he was a NetBeans developer, he probably knows this best.

Anyway, I'm closing this issue because there is no chance I can do anything about it. It might be reasonable for the Tooling API to provide the possiblity to disable automatically getting the proxy from NetBeans but this is not the case and I have no way to affect the Tooling API.

@kelemen
Copy link
Owner

kelemen commented Feb 24, 2015

I have found a workaround for this issue:

Create an "init.gradle" in "~/.gradle" and add the following code to it:

System.properties.remove('socksProxyHost')
System.properties.remove('socksProxyPort')

The problem is that NetBeans adds these properties as well and Apache's SystemDefaultHttpClient will ignore the non proxy list when the above properties are present.

Sadly, I don't think this solves #146 because the Gradle dist gets downloaded before scripts are executed (for obvious reasons). In that case, you have to disable the proxy in NetBeans for the first run (and may re-enable later).

@kelemen
Copy link
Owner

kelemen commented Oct 24, 2016

Added workaround to automatically apply the following code through init scripts:

System.properties.remove('socksProxyHost')
System.properties.remove('socksProxyPort')

That is, you no longer need to add these lines manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants