-
Notifications
You must be signed in to change notification settings - Fork 0
feature/add-gradle-init #178
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
Open
KevinGruber2001
wants to merge
2
commits into
main
Choose a base branch
from
feat/gradle-daemon-init
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { spawn } from "child_process"; | ||
| import * as fs from "fs"; | ||
| import * as path from "path"; | ||
| import { GradlePrewarmLevel } from "../theia/env-strategy"; | ||
|
|
||
| /** | ||
| * Gradle invocation per prewarm level. Each higher level warms one more phase of | ||
| * the student's first build during session startup (see the prewarming levels L1-L4): | ||
| * - "daemon" (L1): start the Gradle daemon so it is warm and reused. | ||
| * - "deps" (L3): additionally configure the build and resolve/download dependencies. | ||
| * - "full" (L4): additionally compile, leaving the first build near-instant. | ||
| * "off" disables prewarming and is handled before this map is used. | ||
| */ | ||
| const PREWARM_ARGS: Record<Exclude<GradlePrewarmLevel, "off">, string[]> = { | ||
| daemon: ["--daemon", "help"], | ||
| deps: ["--daemon", "dependencies"], | ||
| full: ["--daemon", "build", "-x", "test"], | ||
| }; | ||
|
|
||
| /** | ||
| * Pre-warms the Gradle build in the background after cloning a repository, so the | ||
| * student's first build can skip the phases warmed here. Runs detached and never | ||
| * blocks the caller. | ||
| * | ||
| * Silently skips if: | ||
| * - Prewarming is disabled (`level` is "off") | ||
| * - Running on Windows (not a supported environment) | ||
| * - The project does not contain a `gradlew` file (not a Gradle project) | ||
| */ | ||
| export function warmupGradleDaemon( | ||
| projectPath: string, | ||
| level: GradlePrewarmLevel = "daemon", | ||
| ): void { | ||
| if (level === "off" || process.platform === "win32") { | ||
| return; | ||
| } | ||
|
|
||
| const gradlewPath = path.join(projectPath, "gradlew"); | ||
| if (!fs.existsSync(gradlewPath)) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| fs.chmodSync(gradlewPath, 0o755); | ||
|
|
||
| const child = spawn("./gradlew", PREWARM_ARGS[level], { | ||
| cwd: projectPath, | ||
| detached: true, | ||
| stdio: "ignore", | ||
| }); | ||
| // Detached failures surface asynchronously via the 'error' event, not the throw below. | ||
| child.on("error", (error) => { | ||
| console.warn(`Gradle prewarm (${level}) failed to start: ${error.message}`); | ||
| }); | ||
| child.unref(); | ||
| } catch (error: any) { | ||
| console.warn(`Gradle prewarm (${level}) failed: ${error.message}`); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.