Gradle,不在Windows上使用NTLM代理 [英] Gradle, not working behind proxy with NTLM on Windows

查看:98
本文介绍了Gradle,不在Windows上使用NTLM代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试一个gradle(这个领域的绝对noob)。

I am just testing out a gradle (an absolute noob in this field).

我在Windows上试试这个。我曾经让Maven在同一台机器上为我做构建和发布。它位于具有NTLM身份验证的代理之后。过去工作正常。然而,某种程度上Gradle并没有为我做这件事。

I am trying this out on Windows box. I used to have Maven do the build and release for me from the same machine. It is behind a proxy with NTLM authentication. And that used to work alright. However, somehow Gradle is not doing that for me.

我的build.gradle有以下配置(除了其他配置)

My build.gradle has the following config (apart from other)

// Java plugin to build our JAR artifact.
apply plugin: 'java'  

// Build stuff with jdk 1.7
sourceCompatibility = 1.7
targetCompatibility = 1.7

// Regular name and version for your project. 
group = 'foo.bar.gradle'
version = '1.0-SNAPSHOT'

// The local maven repository
def localMavenRepo = 'file://C:/ProgramFiles/MavenRepository'

repositories {
// Use the maven central repository. 
mavenCentral()
// ... and the local maven repository.
maven { url localMavenRepo }

// maven { url 'http://www.springsource.com/repository/' }
}


dependencies {
compile 'org.databene:contiperf:2.2.0','org.springframework:spring-webmvc:3.2.0.RELEASE'         
testCompile 'junit:junit:4.11' 
/*compile.exclude module: 'commons'*/
/*all*.exclude*/ 
}

我的/gradle.properties具有以下设置

My /gradle.properties has the following set up

systemProp.proxySet=true
systemProp.http.proxyHost=<proxy name, same as that set in Maven>
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=<domain name>/<user name> 

然而,当我运行此操作时,我收到以下错误

However, when I run this, I get the following error

NEGOTIATE authentication error: No valid credentials provided (Mechanism level:
No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)
)

这是Gradle的1.3版本。请帮忙。

This is in version 1.3 of Gradle. Please help.

更新:
我现在更新为gradle-1.4-rc-3
我的gradle.properties文件看起来现在这样

Update: I have now updated to gradle-1.4-rc-3 My gradle.properties file look like this now

systemProp.proxySet="true"
systemProp.http.keepAlive="true"
systemProp.http.proxyHost=<proxy name> 
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=<domain name>/<username> 

但我仍然继续看到这个问题。我有更多的日志。我在STS(IDE)中看到这个

But I still continue to see the issue. I have got some more logs. I see this in the STS (IDE)

Could not GET 'http://repo1.maven.org/maven2/org/spr...'. Received status code 500 from server: Internal Server Error 
Could not execute build using Gradle installation 'C:\ProgramFiles\gradle-1.4-rc-3'.

不,凭据没有错。在相同的设置中,使用相同的值Maven工作正常。不,gradle.properties也在正确的位置。如果我更改代理的值,则错误会更改。因此,该工具肯定是在读取gradle.properties文件。

And no, the credentials are not wrong. In the same setup, with same values Maven is working fine. And no, the gradle.properties is in correct location as well. If I change the value of the proxy, the error changes. So, the tool is definitely reading the gradle.properties file.

推荐答案

更新:

随着时间的推移,更好的解决方案:

with time, better solution:

添加wagon-http-lightweight扩展名
Wagon HTTP轻量级库在处理NTLM代理时处理Maven 3中的身份验证限制。

Add wagon-http-lightweight extension Wagon HTTP lightweight library deals with authentication limitations in Maven 3 when working with NTLM proxies.

从maven repo下载wagon-http-lightweight-2.2.jar。
将wagon-http-lightweight-2.2.jar复制到%M2_HOME%/ lib / ext文件夹。

Download the wagon-http-lightweight-2.2.jar from maven repo. Copy the wagon-http-lightweight-2.2.jar to %M2_HOME%/lib/ext folder.

原始答案:

我遇到了完全相同的问题。这是微软服务器(ISA等)的常见问题。 NTLM不支持您的应用程序中使用的http标头(至少,直接)


为了绕过这一点,我使用了代理到代理。一个本地代理,它将动态更改http标头,以便Microsoft服务器可以理解您的请求。

I had the exact same problem. It's a common problem with microsoft servers (ISA, etc). The http header used in your application are not supported for NTLM (at least, directly)
To bypass this, I used a "proxy-to-proxy". A local proxy that will change the http header on the fly so that Microsoft servers can understand your request.

基本上,您将在本地发送请求(127.0.0.1)此代理服务器将更改符合NTLM请求的标头,并将其转发到8080端口上的父代理。

Basically you will send your request locally (127.0.0.1) this proxy server will change the header with NTLM compliant request and forward it to the parent proxy on the 8080 port.

两种情况:您是否拥有管理员权限。

Two scenarios: you have Administrators privileged or not.

如果您有管理员权限,可以安装 CNTLM 它将作为服务安装。有一个自动配置安装,你可以检查CNTLM的维基(默认端口:3128)

If you have admin rights, you can install CNTLM It will be installed as a service. There is a "auto-config" install, you can check on the wiki of CNTLM (default port:3128)

如果你没有管理员权限,你可以安装 NTLM APS (即使它已经很老了,它对我有用)

你需要使用您的NT域,主机,父代理+端口,NTLM_TO_BASIC 1
配置server.cfg文件(您可以通过按键盘上的'windows + pause'按钮获取您的域名和主机)
默认端口是5865.

If you don't have Admin rights, you can install NTLM APS (even though it's quite old, it works for me)
you need to configure the server.cfg file with your NT Domain, host, parent proxy + port, NTLM_TO_BASIC 1 (you can get your domain and host by pressing on your keyboard 'windows + pause' buttons) the default port is 5865.

对于NTLMAPS,您需要Python(python portable不需要管理员权限,并更改'runserver.bat'中的值以匹配您的安装)
你还需要使用这个补丁,因为它有一个分组响应的错误

For NTLMAPS, you need Python (python portable doesn't require admin rights, and change the value in 'runserver.bat' to match your install) and you also need to patch the version on sourceforge with this patch because it has a bug with chunked responses

在您的应用程序中,您需要更改代理设置,如下所示:

In your application, you need to change your proxy settings as follow:

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=3128 or 5865 depending on which server you installed

有时微软服务器仍会阻止请求和我需要重新启动本地代理或更改父代理地址。

Sometimes the microsoft server still blocks the requests and I need to restart my local proxy or change parent proxy address.

这篇关于Gradle,不在Windows上使用NTLM代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆