Repository navigation
Why it downloads Gradle when I open a single java file #901
Copy link
Copy link
Open
Labels
Description
The issue is found when I'm using a VM without network access. It's a clean installed Windows, OpenJDK 8u202, VS Code 1.33.1, vscode-java is the only extension installed.
When I open a .java file, vscode activates the extension, and there's an error in the log. Attaching the full log: vscode-java-no-network.log
Why does it have to download the Gradle when I'm not opening a gradle project? IMO it would be good if the downloading only happens when I'm working on a gradle project.
...
!ENTRY org.eclipse.buildship.core 2 0 2019-04-25 13:08:11.621
!MESSAGE Could not load Gradle version information
!STACK 0
org.gradle.api.UncheckedIOException: Cannot download published Gradle versions.
at org.eclipse.buildship.core.internal.util.gradle.PublishedGradleVersions.downloadVersionInformation(PublishedGradleVersions.java:164)
at org.eclipse.buildship.core.internal.util.gradle.PublishedGradleVersions.tryToDownloadAndCacheVersions(PublishedGradleVersions.java:148)
at org.eclipse.buildship.core.internal.util.gradle.PublishedGradleVersions.create(PublishedGradleVersions.java:108)
at org.eclipse.buildship.core.internal.util.gradle.PublishedGradleVersionsWrapper$LoadVersionsJob.run(PublishedGradleVersionsWrapper.java:62)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.net.UnknownHostException: services.gradle.org
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at org.eclipse.buildship.core.internal.util.gradle.PublishedGradleVersions.downloadVersionInformation(PublishedGradleVersions.java:161)
... 4 more
!ENTRY org.eclipse.jdt.ls.core 1 0 2019-04-25 13:08:12.170
!MESSAGE Finished creating the Java project jdt.ls-java-project
...
Reactions are currently unavailable
Activity
fbricon commentedon Apr 26, 2019
This is most likely caused by eagerly activating the Buildship plugin when the server initializes. There might be ways to delay that activation (same thing for M2E) but it might be tricky
tsmaeder commentedon Nov 21, 2019
@fbricon downloading stuff from fixed locations is a problem in airgapped or disconnected cases. Can we ensure somehow we can override all downloads or make sure required stuff is local already? Like we do for maven repos in the maven config in ~/.m2?
snjeza commentedon Nov 21, 2019
@tsmaeder You can try to set the following file - https://services.gradle.org/versions/all
to ~/.tooling/gradle/versions.json
fbricon commentedon Nov 21, 2019
@snjeza Buildship also has an offline preference, we should expose as a jdt.ls setting too. Can you please look into it?
tsmaeder commentedon Nov 21, 2019
I don't understand what you mean. Can you rephrase, @snjeza ?
snjeza commentedon Nov 21, 2019
If there isn't ~/.tooling/gradle/versions.json, Buildship downloads it from https://services.gradle.org/versions/all.
@fbricon it will do it without checking any preferences.
See https://github.com/eclipse/buildship/blob/master/org.eclipse.buildship.core/src/main/java/org/eclipse/buildship/core/internal/util/gradle/PublishedGradleVersions.java#L100 and https://github.com/eclipse/buildship/blob/master/org.eclipse.buildship.core/src/main/java/org/eclipse/buildship/core/internal/util/gradle/PublishedGradleVersionsWrapper.java#L38
snjeza commentedon Nov 21, 2019
@Eskibear you can try to create C:\Users<your_username>.tooling\gradle\versions.json. It can be empty if you don't use Gradle.
snjeza commentedon Nov 21, 2019
The Buildship Offline Mode preference starts a gradle build with the --offline option. See #1157
tsmaeder commentedon Nov 22, 2019
Ok @snjeza , @fbricon thanks for the info. --offline is not what we need for "airgapped". Airgapped is an enironment where you have for example a company intranet, but are not connected to the internet, so we'd have to replace remote servers (repos) with local ones (like we can do in the maven settings). Would
~/.tooling/gradle/versions.jsonallow us to override the server locations? Is there another way to achieve that in gradle? Do you know, @snjeza ?snjeza commentedon Nov 22, 2019
@tsmaeder you may want to take a look at https://chengl.com/gradle-offline-build/ or http://whataboutprogramming.com/work-offline-with-gradle.html
tsmaeder commentedon Nov 25, 2019
@snjeza "offline" is not what we're looking for. We need "airgapped", basically a way to set it up that when a project tries to resolve a project from maven central, it goes to a server somewhere on the local network. Do you happen to know how that can be set up per user or globally?
snjeza commentedon Nov 25, 2019
@tsmaeder see https://docs.gradle.org/current/userguide/init_scripts.html and https://docs.gradle.org/current/userguide/declaring_repositories.html