Reputation: 2326
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.
Upvotes: 10
Views: 23030
Reputation: 768
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
Upvotes: 2
Reputation: 2674
UPDATE:
with time, better solution:
Add wagon-http-lightweight extension Wagon HTTP lightweight library deals with authentication limitations in Maven 3 when working with NTLM proxies.
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.
Original Answer:
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.
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.
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)
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.
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.
Upvotes: 11
Reputation: 181
This is a rather old question, but still one of the first hits when googling for 'gradle' and 'ntlm proxy'. There's not much documentation about it, but if gradle complains about something like
Could not GET 'https://jcenter.bintray.com/org/slf4j/...
and you're using cntlm as your proxy then this command line might be helpful:
gradle test -DproxySet=true -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3128
(assuming default values for proxy name and port). Note the "https" settings. Missing downloads were working successfully with these settings.
Upvotes: 4
Reputation: 4054
I was able to patch Gradle core v1.10 to use BASIC instead of NTLM, and it worked in our environment.
In case you wanted to try, the jar file is here
Use at your own risk.
Upvotes: 0
Reputation: 5140
Seeing that you have your maven repo is under C:\ProgramFiles and not in a typical write-able location such as in a user directory
%USERPROFILE%\.m2\repository || ~/.m2/repository
Your errors may be windows permissions errors ... make sure you check your windows logs and/or try moving your repo to a traditional location ...
Upvotes: 0
Reputation: 1
Gradle depends on Apache HttpClient + jcifs to do NTLM authentication.
There is a bug in HttpClient 4.2.1 and 4.2.2 that can cause issues: there are 2 options for you to try.
systemProp.http.keepAlive="true"
in your gradle.properties
file.Upvotes: 0
Reputation: 6954
I remember working behind an NTLM proxy in the past. As we worked on *nix boxes we couldn't use NTLM proxy as there is no support for it in those OSes. I also don't think that Gradle supports NTLM, but I might be wrong.
Anyway, the thing we used back then was (cntlm)[http://cntlm.sourceforge.net/] proxy and you could do the same thing. Just set it up on your machine and point Gradle's proxy settings at it.
EDIT: Apparently I was wrong - Gradle supports NTLM authentication, see release notes for 1.0-milestone-8
Upvotes: 0