Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"files": "^.secrets.baseline$",
"lines": null
},
"generated_at": "2026-05-29T11:17:59Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -2173,7 +2174,7 @@
"hashed_secret": "87b73e2f494637fa4d733ec1baaaebb07c3ee9d0",
"is_secret": false,
"is_verified": false,
"line_number": 393,
"line_number": 394,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
54 changes: 54 additions & 0 deletions modules/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,60 @@ Create a folder tree which has two bundles, each aiming to test different featur
galasactl project create --package dev.galasa.example.banking --features payee,account --obr --log -
```

### Creating a Manager Project

Instead of creating a test project, you can create a Galasa manager project using the `--manager` flag. A manager is a reusable component that provides test infrastructure and can inject resources into test classes.

Create a manager project:
```
galasactl project create --package dev.galasa.example.docker --manager
```

Create a manager project with a specific manager name:
```
galasactl project create --package dev.galasa.example.docker --manager --managerName docker
```

If `--managerName` is not specified, the tool will use the last part of the package name as the manager name.

Create a manager project with an OBR:
```
galasactl project create --package dev.galasa.example.docker --manager --managerName docker --obr
```

#### Combining Manager and Test Projects

You can create both a manager and test projects in the same command, similar to the SimBank project structure:

```
galasactl project create --package dev.galasa.example --manager --managerName example --features banking,account --obr
```

This creates:
- A manager bundle (`dev.galasa.example.manager`)
- Test projects for each feature (`dev.galasa.example.banking`, `dev.galasa.example.account`)
- A single OBR that includes both the manager and test bundles

#### What Gets Generated

When you create a manager project, the tool generates:

1. **Manager Annotation** (`@ExampleManager`) - Used to inject the manager into test classes
2. **Manager Interface** (`IExampleManager`) - Public API for the manager
3. **Manager Implementation** (`ExampleManagerImpl`) - Internal implementation with lifecycle methods:
- `initialise()` - Called when the manager is first loaded
- `youAreRequired()` - Called when a test needs this manager
- `provisionGenerate()` - Called before test execution to provision resources
- `provisionDiscard()` - Called after test execution to clean up resources
4. **Resource Interface** (`IExampleResource`) - Public API for resources provided by the manager
5. **Resource Implementation** (`ExampleResourceImpl`) - Implementation of the resource
6. **Manager Field** (`ExampleManagerField`) - Handles annotation-based field injection
7. **Manager Exception** (`ExampleManagerException`) - Custom exception for manager errors
8. **Unit Test** (`ExampleManagerImplTest`) - Basic unit test for the manager implementation
9. **Build Files** - Maven (`pom.xml`) and/or Gradle (`build.gradle`, `bnd.bnd`) configuration
10. **OBR Project** (if `--obr` flag is used) - OSGi Bundle Repository configuration

The generated manager follows best practices from existing Galasa managers and includes proper OSGi bundle configuration with Export-Package and Import-Package declarations.
Comment thread
eamansour marked this conversation as resolved.

### Building the example project

Expand Down
79 changes: 76 additions & 3 deletions modules/cli/build-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function download_dependencies {
#--------------------------------------------------------------------------
# Download the dependencies we define in gradle into a local folder
h2 "Downloading dependencies"
gradle --warning-mode all --info --debug installJarsIntoTemplates
gradle --warning-mode all --info --debug -PsourceMaven=${SOURCE_MAVEN} installJarsIntoTemplates
rc=$? ; if [[ "${rc}" != "0" ]]; then error "Failed to run the gradle build to get our dependencies. rc=${rc}" ; exit 1 ; fi
success "OK"
}
Expand Down Expand Up @@ -309,6 +309,53 @@ function generate_sample_code {
success "OK"
}

#--------------------------------------------------------------------------
# Invoke the galasactl command to create a manager project.
function generate_manager_project {
h2 "Invoke the tool to create a sample manager project."

BUILD_SYSTEM_FLAGS=$*

cd $BASEDIR/temp

export MANAGER_PACKAGE_NAME="dev.galasa.example.docker"
${BASEDIR}/bin/${galasactl_command} project create --development --package ${MANAGER_PACKAGE_NAME} --manager --managerName docker --obr ${BUILD_SYSTEM_FLAGS}
rc=$?
if [[ "${rc}" != "0" ]]; then
error " Failed to create the galasa manager project using galasactl command. rc=${rc}"
exit 1
fi
success "OK"
}

#--------------------------------------------------------------------------
# Now build the manager source it created using maven
function build_generated_manager_maven {
h2 "Building the sample manager project we just generated."
cd ${BASEDIR}/temp/${MANAGER_PACKAGE_NAME}
mvn clean test install
rc=$?
if [[ "${rc}" != "0" ]]; then
error " Failed to build the generated manager source code which galasactl created."
exit 1
fi
success "OK"
}

#--------------------------------------------------------------------------
# Now build the manager source it created using gradle
function build_generated_manager_gradle {
h2 "Building the sample manager project we just generated."
cd ${BASEDIR}/temp/${MANAGER_PACKAGE_NAME}
gradle -PsourceMaven=${SOURCE_MAVEN} build publishToMavenLocal
rc=$?
if [[ "${rc}" != "0" ]]; then
error " Failed to build the generated manager source code which galasactl created."
exit 1
fi
success "OK"
}

#--------------------------------------------------------------------------
# Now build the source it created using maven
function build_generated_source_maven {
Expand All @@ -328,7 +375,7 @@ function build_generated_source_maven {
function build_generated_source_gradle {
h2 "Building the sample project we just generated."
cd ${BASEDIR}/temp/${PACKAGE_NAME}
gradle build publishToMavenLocal
gradle -PsourceMaven=${SOURCE_MAVEN} build publishToMavenLocal
rc=$?
if [[ "${rc}" != "0" ]]; then
error " Failed to build the generated source code which galasactl created."
Expand Down Expand Up @@ -518,7 +565,7 @@ function generate_galasactl_documentation {
# Call the documentation generator, which builds .md files into the a location it can be zipped up and shared via maven.
h2 "Publishing the documentation zip to maven local repo so it can be used in the web site"
cd $BASEDIR
cmd="gradle --warning-mode All --info --stacktrace -PtargetMaven=${HOME}/.m2/repository publish"
cmd="gradle --warning-mode All --info --stacktrace -PsourceMaven=${SOURCE_MAVEN} -PtargetMaven=${HOME}/.m2/repository publish"
info "Command is ${cmd}"
$cmd
rc=$? ; if [[ "${rc}" != "0" ]]; then error "Failed to publish the cli documentation zip to maven. rc=${rc}" ; exit 1 ; fi
Expand Down Expand Up @@ -704,6 +751,32 @@ else
build_generated_source_gradle
run_test_locally_using_galasactl ${BASEDIR}/temp/local-run-log-gradle.txt

# Test manager project creation with Maven
h1 "Testing manager project creation with Maven"
cleanup_temp
galasa_home_init
generate_manager_project --maven
cleanup_local_maven_repo
build_generated_manager_maven

# Test manager project creation with Gradle
h1 "Testing manager project creation with Gradle"
cleanup_temp
galasa_home_init
generate_manager_project --gradle
cleanup_local_maven_repo
build_generated_manager_gradle

# Test manager project creation with both Maven and Gradle
h1 "Testing manager project creation with both Maven and Gradle"
cleanup_temp
galasa_home_init
generate_manager_project --maven --gradle
cleanup_local_maven_repo
build_generated_manager_maven
cleanup_local_maven_repo
build_generated_manager_gradle

fi

if [[ "$detectsecrets" == "true" ]]; then
Expand Down
18 changes: 10 additions & 8 deletions modules/cli/docs/generated/galasactl_project_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ galasactl project create [flags]
### Options

```
--development Use bleeding-edge galasa versions and repositories.
--features string A comma-separated list of features you are testing. These must be able to form parts of a java package name. For example: "payee,account" (default "feature1")
--force Force-overwrite files which already exist.
--gradle Generate gradle build artifacts. Can be used in addition to the --maven flag.
-h, --help Displays the options for the 'project create' command.
--maven Generate maven build artifacts. Can be used in addition to the --gradle flag. If this flag is not used, and the gradle option is not used, then behaviour of this flag defaults to true.
--obr An OSGi Object Bundle Resource (OBR) project is needed.
--package string Java package name for tests we create. Forms part of the project name, maven/gradle group/artifact ID, and OSGi bundle name. It may reflect the name of your organisation or company, the department, function or application under test. For example: dev.galasa.banking.example
--development Use bleeding-edge galasa versions and repositories.
--features string A comma-separated list of features you are testing. These must be able to form parts of a java package name. For example: "payee,account". Can be used with --manager flag to create both manager and test projects. (default "feature1")
--force Force-overwrite files which already exist.
--gradle Generate gradle build artifacts. Can be used in addition to the --maven flag.
-h, --help Displays the options for the 'project create' command.
--manager Create a Galasa manager project instead of a test project. A manager provides reusable test infrastructure and can inject resources into test classes.
--managerName string Name of the manager to create. If not specified, defaults to the last part of the package name. For example, 'example' for package 'dev.galasa.example'. Must be a valid Java identifier.
--maven Generate maven build artifacts. Can be used in addition to the --gradle flag. If this flag is not used, and the gradle option is not used, then behaviour of this flag defaults to true.
--obr An OSGi Object Bundle Resource (OBR) project is needed.
--package string Java package name for tests we create. Forms part of the project name, maven/gradle group/artifact ID, and OSGi bundle name. It may reflect the name of your organisation or company, the department, function or application under test. For example: dev.galasa.banking.example
```

### Options inherited from parent commands
Expand Down
Loading
Loading