Skip to content

Conversation

vmadalin
Copy link
Contributor

@vmadalin vmadalin commented May 15, 2024

Context

The Daemon toolchain auto-provisioning mechanism is part of Phase 2 of toolchain support for Gradle Daemon, where the motivation behind it and other technical details can be found on the public spec document. This
PR adds the capability for the auto-provisioning mechanism to download the toolchain given the specified url on the gradle/gradle-daemon-jvm.properties, supporting as well local files.

Here is the summary about the changes:

  • Reuse SecureFileDownloader from resources-http on the Launcher by creating an abstraction for SecureFileDownloader.createExternalResource called ExternalResourceFactory allowing to have two different implementations for daemon and tasks toolchain, since this last one is using many services outside of the scope of the Launcher
  • Moved JavaToolchainQueryService and its dependencies from toolchain-jvm to toolchain-jvm-shared so it can be reused from the launcher
  • Scope JavaToolchainQueryService at a higher level #24353
    • This was marked as Global and Project for now since it requires a major refactor to keep just Global, allowing to reuse this from the Launcher. The same approach has been taken for FileResourceListener where EventScope now allows an array of scopes similar to ServiceScope to be able to support FileResourceConnector for local file urls
    • This allowed to remove the DaemonJavaToolchainQueryService implementation by reusing the JavaToolchainQueryService from the Launcher
  • Created a new JavaToolchainSpec called DaemonJvmToolchainSpec allowing to create it based on PropertyFactory which is available on the Launcher. This is required for JavaToolchainQueryService.findMatchingToolchain
  • Use ProgressLoggerFactory to display the downloading progress for the toolchain
  • Use HttpResourceAccessor instead of UrlExternalResource since the last one doesn’t return the metadata containing the file name
  • AbstractProgressLoggingHandler.ProgressLoggingInputStream moved to separate file so it can be reused
  • Add more generic listener called ProgressLoggingInputSteamListener to ProgressLoggingInputStream to capture read operation progress instead of build specific ResourceOperation
  • Implemented ToolchainDownloadProgressListener which is responsible for sending proper everts to display downloading toolchain progress on the CLI and TAPI:
    • Important the DefaultToolingImplementationLoader was modified to include Download progress related events for TAPI since this was causing them to be ignored due to classloader conflict causing for DefaultFileDownloadStartEvent:
CastException: Cannot cast object 'Download https://cdn.azul.com/zulu/bin/zulu19.32.13-ca-jdk19.0.2-macosx_aarch64.zip started' with class 'org.gradle.tooling.events.download.internal.DefaultFileDownloadStartEvent' to class 'org.gradle.tooling.events.download.internal.DefaultFileDownloadStartEvent'
Cause: loader constraint violation: when resolving method 'void org.gradle.tooling.events.download.internal.DefaultFileDownloadOperationDescriptor.<init>(java.lang.String, java.net.URI, org.gradle.tooling.events.OperationDescriptor)' the class loader org.gradle.internal.classloader.VisitableURLClassLoader @67ad0239 of the current class,

NOTE: This change was built on top of #29022 to avoid merge conflicts.

Tests

Demo

Simple demo exposing how auto-provisioning mechanism download the daemon toolchain from the specified url or from a local file. Note that the error is because of missing installation part, which will be addressed separately

  • CLI
Daemon.toolchain.downloaded.by.auto-provisioning.mechanism.mov
  • TAPI
Screen.Recording.2024-05-28.at.15.28.54.mov

Contributor Checklist

  • Review Contribution Guidelines
  • Make sure that all commits are signed off to indicate that you agree to the terms of Developer Certificate of Origin.
  • Make sure all contributed code can be distributed under the terms of the Apache License 2.0, e.g. the code was written by yourself or the original code is licensed under a license compatible to Apache License 2.0.
  • Check "Allow edit from maintainers" option in pull request so that additional changes can be pushed by Gradle team
  • Provide integration tests (under <subproject>/src/integTest) to verify changes from a user perspective
  • Provide unit tests (under <subproject>/src/test) to verify logic
  • Update User Guide, DSL Reference, and Javadoc for public-facing changes
  • Ensure that tests pass sanity check: ./gradlew sanityCheck
  • Ensure that tests pass locally: ./gradlew <changed-subproject>:quickTest

Copy link

gitstream-cm bot commented May 15, 2024

There are new TODOs present in this change. Should any be removed?

@ov7a ov7a removed the to-triage label May 16, 2024
@vmadalin vmadalin force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch 2 times, most recently from d580e6a to cd5bc8b Compare May 18, 2024 16:53
@big-guy big-guy added this to the 8.10 RC1 milestone May 20, 2024
@big-guy big-guy self-assigned this May 20, 2024
@vmadalin vmadalin force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch from cd5bc8b to b7b9880 Compare May 20, 2024 13:45
Copy link

gitstream-cm bot commented May 20, 2024

Change Summary

This PR is 75.98% new code.
Platform Added Lines % of Total Line Changes Deleted Lines % of Total Line Changes Files Changed % of Total Files Changed
bt_ge_build_cache 0 0% 0 0% 0 0%
build_infrastructure 0 0% 0 0% 0 0%
core_configuration 0 0% 0 0% 0 0%
core_execution 1499 54.63% 435 15.85% 51 49.51%
core_runtime 1499 54.63% 435 15.85% 51 49.51%
documentation 0 0% 0 0% 0 0%
extensibility 0 0% 0 0% 0 0%
gradle_enterprise 0 0% 0 0% 0 0%
ide 0 0% 0 0% 0 0%
jvm 414 15.09% 164 5.98% 40 38.83%
kotlin_dsl 0 0% 0 0% 0 0%
release_coordination 0 0% 0 0% 0 0%
software 153 5.58% 49 1.79% 8 7.77%

@vmadalin vmadalin force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch 4 times, most recently from ab7d661 to 134a1cc Compare May 30, 2024 09:31
@vmadalin vmadalin force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch from 134a1cc to a9fced2 Compare June 11, 2024 12:21
@big-guy big-guy modified the milestones: 8.10 RC1, 8.11 RC1 Aug 5, 2024
@vmadalin vmadalin force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch from a9fced2 to 6714182 Compare August 27, 2024 15:30
@vmadalin vmadalin changed the base branch from release to master August 27, 2024 15:31
@vmadalin vmadalin force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch from 6714182 to ce6d532 Compare August 29, 2024 12:26
@vmadalin vmadalin marked this pull request as ready for review August 29, 2024 13:48
@vmadalin vmadalin requested review from a team as code owners August 29, 2024 13:48
@vmadalin vmadalin requested a review from a team August 29, 2024 13:48
@vmadalin vmadalin requested a review from a team as a code owner August 29, 2024 13:48
@ljacomet ljacomet enabled auto-merge January 27, 2025 13:54
@ljacomet ljacomet added this pull request to the merge queue Jan 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 27, 2025
@ljacomet

This comment has been minimized.

@bot-gradle

This comment has been minimized.

@bot-gradle
Copy link
Collaborator

The following builds have failed:

@ljacomet ljacomet force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch from fc3d3ac to 5335b79 Compare January 28, 2025 15:57
@ljacomet
Copy link
Member

@bot-gradle test PT

@bot-gradle

This comment has been minimized.

@bot-gradle
Copy link
Collaborator

The following builds have failed:

@ljacomet ljacomet force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch 2 times, most recently from 7f8ec77 to ecf204c Compare January 29, 2025 15:13
vmadalin and others added 5 commits January 29, 2025 16:13
Moving higher is currently blocked by, at least, the transitive usage of
`RepositoryTransportFactory` which is `Build` scoped.

Fixes gradle#24353
This is no longer needed following refactors that enable using a
DefaultToolchainSpec instead.
We cannot have such a dependency as it impacts classloading of Gradle
core and plugins, breaking use cases due to the class loading hierarchy
changes this causes.

Instead classes needed for the daemon toolchain work were moved to
logging or resources projects which are part of core.
The infrastructure needs to use launcher/daemon side events, that are
then translated by the tooling API protocol.
By reusing this infra, there is no need to update the TAPI client in
IDEs to get the download events as long as the IDE already integrated
with those events available since Gradle 7.3
@ljacomet ljacomet force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch from ecf204c to 29b1f6f Compare January 29, 2025 15:13
@ljacomet ljacomet enabled auto-merge January 29, 2025 15:14
@ljacomet ljacomet added this pull request to the merge queue Jan 29, 2025
auto-merge was automatically disabled January 29, 2025 15:49

Pull Request is not mergeable

@ljacomet ljacomet removed this pull request from the merge queue due to a manual request Jan 29, 2025
Those services are only required when using the daemon tooclhain feature
and no daemon is available. The lazy initializations makes sure only
launchers in that configuration pay the price for those services
creation.
@ljacomet ljacomet force-pushed the daemon-toolchain-auto-provisioning-download-toolchain branch from 29b1f6f to 26211a0 Compare January 29, 2025 16:28
@ljacomet ljacomet enabled auto-merge January 29, 2025 16:28
@ljacomet ljacomet added this pull request to the merge queue Jan 29, 2025
Merged via the queue into gradle:master with commit 156d346 Jan 29, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:contributor PR by an external contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scope JavaToolchainQueryService at a higher level
7 participants