Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle, not working behind proxy with NTLM on Windows

Tags:

java

gradle

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

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.

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*/ 
}

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)
)

This is in version 1.3 of Gradle. Please help.

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> 

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'.

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.

like image 919
partha Avatar asked Jan 21 '13 07:01

partha


People also ask

What is NTLM proxy authentication?

What is NTLM? NT LAN Manager known as NTLM is a Microsoft proprietary Authentication Protocol used in Windows for authenticating between clients and servers. With this new feature, UXI sensors can now access a web server URL via a proxy that requires NTLM authentication.


1 Answers

This worked for me, am using gradle-6.3. Place the following in gradle.properties

Note that we usually give domain-name\user-name while logging into Windows machine, but the value to be give would be domain-name/user-name. Also your password need not be hex-encoded, and if your password contains 'equal to' character, gradle picks all value 'after' first '=' (from the left) as your password.

systemProp.http.proxyHost=proxy-ip-or-name
systemProp.http.proxyPort=proxy-port 
systemProp.http.proxyUser=domain-name/user-name 
systemProp.http.proxyPassword=your-password-without-any-encoding

systemProp.https.proxyHost=proxy-ip-or-name 
systemProp.https.proxyPort=proxy-port 
systemProp.https.proxyUser=domain-name/user-name 
systemProp.https.proxyPassword=your-password-without-any-encoding
like image 74
Siva Avatar answered Sep 19 '22 14:09

Siva