An Architect plugin that integrates Gradle build tasks into the Architect workflow system, enabling seamless Gradle project management.
The Gradle Architected plugin provides integration between Gradle build tools and the Architect platform. It allows you to:
- Execute Gradle tasks within the Architect workflow
- Manage multi-module Gradle projects
- Configure project-specific Gradle settings
- Publish packages to GitHub Packages
The plugin maps Gradle tasks to Architect workflow phases:
| Architect Phase | Gradle Task | Purpose |
|---|---|---|
INIT |
(none) | Initialize Gradle context |
BUILD |
build |
Compile and assemble project |
TEST |
test |
Run unit tests |
RUN |
run |
Execute the application |
PUBLISH |
publishGprPublicationToGitHubPackagesRepository |
Publish to GitHub Packages |
Configure multiple Gradle projects within a single Architect project:
gradle:
projects:
- name: "api"
path: "api"
gradlePath: "./gradlew"
- name: "web"
path: "web"
gradlePath: "../gradlew"
githubPackageRelease: trueTasks can be conditionally enabled based on project configuration:
githubPackageRelease: Controls whether the project should be published to GitHub Packages
- GradlePlugin: Main plugin class implementing
ArchitectPlugin - GradleTask: Task executor for Gradle commands
- GradleContext: Container for all Gradle project configurations
- GradleProjectContext: Configuration for individual Gradle projects
GradleContext(
projects: List<GradleProjectContext>
)
GradleProjectContext(
name: String, // Project identifier
path: String, // Relative path from root
githubPackageRelease: Boolean, // Enable publishing
gradlePath: String // Path to gradlew script
)- Phase:
INIT - Purpose: Initialize Gradle context
- Command: (none)
- Phase:
BUILD - Purpose: Build all configured projects
- Command:
./gradlew build
- Phase:
TEST - Purpose: Run tests for all projects
- Command:
./gradlew test
- Phase:
RUN - Purpose: Run application
- Command:
./gradlew run
- Phase:
PUBLISH - Purpose: Publish to GitHub Packages
- Command:
./gradlew publishGprPublicationToGitHubPackagesRepository - Condition: Only runs if
githubPackageReleaseis enabled
cd app
./gradlew buildNote: Building requires access to the Architect API package. Set the following environment variables:
GITHUB_USERorgithubUserpropertyREGISTRY_TOKENorGITHUB_TOKENenvironment variable
Add the plugin configuration to your architect.yml:
gradle:
projects:
- name: "main"
path: "."gradle:
projects:
- name: "core"
path: "core"
gradlePath: "../gradlew"
- name: "api"
path: "api"
gradlePath: "../gradlew"
- name: "web"
path: "web"
gradlePath: "../gradlew"
githubPackageRelease: truegradle:
projects:
- name: "legacy"
path: "legacy-module"
gradlePath: "./legacy-module/gradlew"To enable GitHub Package publishing for a project:
gradle:
projects:
- name: "library"
path: "lib"
githubPackageRelease: true- Task Invocation: Architect invokes a Gradle task (e.g.,
build) - Project Iteration: The plugin iterates over all configured projects
- Condition Check: Validates if task should run for each project
- Command Execution: Runs the Gradle command in the project directory
- Result Aggregation: Collects results from all projects
- Success Check: Fails if any project task fails
- Language: Kotlin 1.9.25
- JVM: Java 17
- Dependencies: Architect API 1.1.2
- Build Tool: Gradle 8.14.3
To add a new Gradle task to the plugin:
registry.add(
GradleTask(
"taskName", // Gradle command
WorkflowPhase.PHASE, // Architect phase
context // Gradle context
)
)For tasks that should only run under certain conditions:
registry.add(
GradleTask(
"taskName",
WorkflowPhase.PHASE,
context
) { projectContext ->
projectContext.someCondition // Return Boolean
}
)The CommandExecutor service is used to run Gradle commands:
commandExecutor.execute(
"${gradleProjectContext.gradlePath} taskName ${args.joinToString(" ")}",
workingDir = gradleProjectDir.toString()
)The plugin provides robust error handling:
- Project-level Failures: Each project failure is captured separately
- Detailed Messages: Exceptions include project context
- Aggregated Results: Overall task result shows all project statuses
- Early Exit: Task fails if any project fails
Task results are hierarchical:
✅ Gradle task: gradle-build executed successfully for all projects
├── ✅ Gradle task: gradle-build over gradle project: core completed successfully
├── ✅ Gradle task: gradle-build over gradle project: api completed successfully
└── ✅ Gradle task: gradle-build over gradle project: web completed successfully
- Use Relative Paths: Configure paths relative to the project root
- Shared Gradle Wrapper: Use a single
gradlewfor all modules when possible - Conditional Publishing: Only enable
githubPackageReleasefor library projects - Error Handling: Ensure Gradle tasks return proper exit codes
- Working Directory: Let the plugin manage working directories for each project
- Gradle must be installed or a Gradle wrapper must be available
- Project paths are relative to the Architect project root
- Gradle tasks must support command-line execution
- Publishing requires proper GitHub credentials configuration in Gradle