-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
196 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,20 @@ | ||
{ | ||
"name": "gradlew", | ||
"batchImplementation": "./src/executors/gradlew/gradlew.impl#batchGradlew", | ||
"implementation": "/packages/gradle/src/executors/gradlew/gradlew.impl.ts", | ||
"schema": { | ||
"$schema": "https://json-schema.org/schema", | ||
"version": 2, | ||
"title": "GradlewImpl executor", | ||
"description": "The GradlewImpl executor is used to run Gradle tasks.", | ||
"type": "object", | ||
"properties": {}, | ||
"required": [], | ||
"presets": [] | ||
}, | ||
"description": "gradlew.impl executor", | ||
"aliases": [], | ||
"hidden": false, | ||
"path": "/packages/gradle/src/executors/gradlew/schema.json", | ||
"type": "executor" | ||
} |
This file contains 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 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 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,10 @@ | ||
{ | ||
"executors": { | ||
"gradlew": { | ||
"batchImplementation": "./src/executors/gradlew/gradlew.impl#batchGradlew", | ||
"implementation": "./src/executors/gradlew/gradlew.impl", | ||
"schema": "./src/executors/gradlew/schema.json", | ||
"description": "gradlew.impl executor" | ||
} | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -39,5 +39,6 @@ | |
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
}, | ||
"executors": "./executors.json" | ||
} |
This file contains 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 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,67 @@ | ||
import { ExecutorContext, TaskGraph } from '@nx/devkit'; | ||
import runCommandsImpl, { | ||
RunCommandsOptions, | ||
} from 'nx/src/executors/run-commands/run-commands.impl'; | ||
import { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages'; | ||
|
||
const MAX_PROJECTS_IN_BATCH = 10; | ||
|
||
export async function graldewExecutor( | ||
options: RunCommandsOptions, | ||
context: ExecutorContext | ||
): Promise<{ success: boolean }> { | ||
const results = await runCommandsImpl(options, context); | ||
return { success: results.success }; | ||
} | ||
|
||
export default graldewExecutor; | ||
|
||
export async function batchGradlew( | ||
taskGraph: TaskGraph, | ||
inputs: Record<string, RunCommandsOptions>, | ||
overrides: RunCommandsOptions, | ||
context: ExecutorContext | ||
): Promise<BatchResults> { | ||
const regex = /[./\\]*gradlew[\w.-]*/; | ||
|
||
let gradlewCommand: string | undefined; | ||
const roots = taskGraph.roots.slice(0, MAX_PROJECTS_IN_BATCH); | ||
const tasksRan = []; | ||
const results: BatchResults = {}; | ||
|
||
const gradlewTasks = roots.flatMap((task) => { | ||
const gradlewTask = inputs[task].command; | ||
if (typeof gradlewTask !== 'string') return []; | ||
|
||
const match = gradlewTask.match(regex); | ||
if (!match) return []; | ||
results[task] = { success: false, terminalOutput: '' }; | ||
|
||
tasksRan.push(task); | ||
|
||
gradlewCommand = match[0]; // Store the first found gradlewCommand | ||
return gradlewTask.replace(gradlewCommand, '').trim(); | ||
}); | ||
|
||
const startTime = Date.now(); | ||
const { success, terminalOutput } = await runCommandsImpl( | ||
{ | ||
command: `${gradlewCommand} ${gradlewTasks.join(' ')} --parallel`, | ||
__unparsed__: [], | ||
...(overrides ?? {}), | ||
}, | ||
context | ||
); | ||
const endTime = Date.now(); | ||
|
||
tasksRan.forEach((task) => { | ||
results[task] = { | ||
success, | ||
terminalOutput, | ||
startTime, | ||
endTime, | ||
}; | ||
}); | ||
|
||
return results; | ||
} |
This file contains 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,9 @@ | ||
{ | ||
"$schema": "https://json-schema.org/schema", | ||
"version": 2, | ||
"title": "GradlewImpl executor", | ||
"description": "The GradlewImpl executor is used to run Gradle tasks.", | ||
"type": "object", | ||
"properties": {}, | ||
"required": [] | ||
} |
This file contains 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 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