srs / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
864 stars 212 forks source link

Add Proxy Support for Download #63

Open yellek opened 9 years ago

yellek commented 9 years ago

Despite having a working proxy configuration for gradle the download still fails with a HTTP 407 error.

srs commented 9 years ago

Hi.

Can you show me how you set up your proxy in gradle?

Thanks.

yellek commented 9 years ago

In gradle.properties:

systemProp.http.proxyHost=localhost systemProp.http.proxyPort=3128 systemProp.http.nonProxyHosts=localhost systemProp.https.proxyHost=localhost systemProp.https.proxyPort=3128 systemProp.https.nonProxyHosts=localhost

This references a cntlm proxy I have running on my local machine to deal with windows proxy weirdness.

neversleepz commented 9 years ago

@yellek is the 407 from Gradle or the result of running npm from gradle? I am guessing the plugin calls out to npm which is configured differently I've had some shocking trouble behind ntlm proxies in some corporations too and even the above wont help.

computerlove commented 8 years ago

I am behind a proxy, and with latest node and npm everything worked with proxy set as abose plus .npmrc:

https-proxy=... proxy=...

Exordian commented 7 years ago

a hacky workaround to use JVM http settings. the finalizedBy dependency could be added to npmInstall aswell unfortunately our gulp tasks require them aswell

npmInstall.dependsOn 'npmHttpProxy'
npmInstall.dependsOn 'npmHttpsProxy'
gulpBuild.finalizedBy 'removeNpmHttpProxy'
gulpBuild.finalizedBy 'removeNpmHttpsProxy'

task npmHttpProxy(type: NpmTask, group: 'node') {
    args = ['config', 'set', 'proxy', "http://${-> System.properties["http.proxyHost"]}:${-> System.properties["http.proxyPort"]}"]
}

task removeNpmHttpProxy(type: NpmTask, group: 'node') {
    args = ['config', 'delete', 'proxy']
}

task npmHttpsProxy(type: NpmTask, group: 'node') {
    args = ['config', 'set', 'https-proxy', "http://${-> System.properties["https.proxyHost"]}:${-> System.properties["https.proxyPort"]}"]
}

task removeNpmHttpsProxy(type: NpmTask, group: 'node') {
    args = ['config', 'delete', 'https-proxy']
}
npmHttpProxy.onlyIf { System.properties.containsKey("http.proxyHost") }
npmHttpsProxy.onlyIf { System.properties.containsKey("https.proxyHost") }