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

NullPointerException when using Scalafmt.withMavenRepositories from Gradle #1618

Closed
augi opened this issue Jan 3, 2020 · 2 comments
Closed

Comments

@augi
Copy link

augi commented Jan 3, 2020

In gradle-scalafmt, we started using withMavenRepositories method when configuring Scalafmt. Unfortunately, the build then sometimes (esp. in clean environment, without anything cached) fails with following error:

  Caused by: java.lang.NullPointerException: Username must not be null!
  	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:910)
  	at org.gradle.internal.resource.transport.http.ntlm.NTLMCredentials.<init>(NTLMCredentials.java:36)
  	at org.gradle.internal.resource.transport.http.HttpClientConfigurer.useCredentials(HttpClientConfigurer.java:197)
  	at org.gradle.internal.resource.transport.http.HttpClientConfigurer.configureCredentials(HttpClientConfigurer.java:139)
  	at org.gradle.internal.resource.transport.http.HttpClientConfigurer.configure(HttpClientConfigurer.java:109)
  	at org.gradle.internal.resource.transport.http.HttpClientHelper.getClient(HttpClientHelper.java:195)

Also a user of gradle-scalafmt reported this as an issue.

It seems that this happens only if scalafmt is executed before scalaCompile. If scalaCompile goes first then it correctly download all dependencies (to the cache) and scalafmt goes well then as well.

Maybe it is a bug in coursier that is used under the hood?

@olafurpg
Copy link
Member

olafurpg commented Jan 3, 2020

Thank you for reporting! The stack trace doesn’t point to scalafmt, can you please include what Scalafmt method is failing?

@augi
Copy link
Author

augi commented Jan 3, 2020

Sorry for bothering you with this. It seems that it was a strange error in gradle-scalafmt. I don't know why but this change to make the code more Groovish apparently fixed the issue.

@augi augi closed this as completed Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants