Executes a specified Maven command in the designated working directory within the scaffolder workspace.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| args | array | - | |
| command | string | The maven command to run | |
| workingDirectory | string | Working directory within the scaffolder workspace to execute the command in |
Output Schema
Usage Examples
Build and package a Java service
Runs mvn clean package in the workspace root to compile and package the service. Use this right after fetching sources with fetch:template.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme-org/java-service-template/archive/main.tar.gz
targetPath: .
values:
name: ${{ parameters.componentName }}
javaVersion: 17
- id: maven-build
action: maven
input:
command: clean package
workingDirectory: .
args:
- -DskipTests=true
- -BRun tests with a Maven profile in a submodule
Executes mvn test in a specific subdirectory with a selected profile. Use this when the template generates a multi-module project and you want to test one module.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme-org/multi-module-java/archive/main.tar.gz
targetPath: .
values:
rootPackage: com.acme.payments
- id: module-tests
action: maven
input:
command: test
workingDirectory: services/payment-service
args:
- -P ${{ parameters.mavenProfile }}
- -Dspring.profiles.active=${{ parameters.mavenProfile }}
- -BBuild an OCI image using Spring Boot plugin
Runs the Spring Boot build-image goal to create a container image. Use this after building the JAR to produce a deployable image.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme-org/spring-boot-service/archive/main.tar.gz
targetPath: .
values:
name: ${{ parameters.componentName }}
- id: build-image
action: maven
input:
command: spring-boot:build-image
workingDirectory: .
args:
- -DskipTests=true
- -Dspring-boot.build-image.imageName=ghcr.io/acme/${{ parameters.componentName }}:latest
- -BDeploy artifacts to an internal Maven repository
Runs mvn deploy with a custom settings file and repository configuration. Use this to publish artifacts to Nexus or Artifactory from the scaffolder.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme-org/inventory-service/archive/main.tar.gz
targetPath: .
values:
name: inventory-service
- id: maven-deploy
action: maven
input:
command: deploy
workingDirectory: services/inventory-service
args:
- -DskipTests=true
- -s .mvn/settings.xml
- -DaltDeploymentRepository=internal-releases::default::https://nexus.example.com/repository/maven-releases/
- -BBuild selected modules with parallelization
Builds only specific modules with mvn clean install using -pl and enables parallel builds. Use this to speed up multi-module builds and avoid building everything.
steps:
- id: fetch-template
action: fetch:template
input:
url: https://github.com/acme-org/multi-module-java/archive/main.tar.gz
targetPath: .
values:
modules:
- service-a
- service-b
- id: selective-build
action: maven
input:
command: clean install
workingDirectory: .
args:
- -pl
- service-a,service-b
- -am
- -T
- 1C
- -Drevision=${{ parameters.version }}
- -DskipTests=${{ parameters.skipTests }}
- -B