Skip to content

Commit f62ae26

Browse files
committed
AMP-187 Add gradlew and wrapper to run gradle tasks
1 parent 47d554b commit f62ae26

File tree

10 files changed

+287
-41
lines changed

10 files changed

+287
-41
lines changed

.github/workflows/ci-build-publish.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }}
7575
run: |
7676
echo "Building with ARTEFACT_VERSION=$ARTEFACT_VERSION"
77-
gradle build -DARTEFACT_VERSION=$ARTEFACT_VERSION
77+
./gradlew build -DARTEFACT_VERSION=$ARTEFACT_VERSION
7878
7979
- name: Extract repo name
8080
id: repo_vars
@@ -114,7 +114,7 @@ jobs:
114114
- name: Run API Tests
115115
run: |
116116
cd apiTest
117-
gradle test
117+
../gradlew test
118118
119119
- name: Upload test reports
120120
if: always()
@@ -162,7 +162,7 @@ jobs:
162162
163163
echo "Publishing artefact for version: $ARTEFACT_VERSION"
164164
165-
gradle publish \
165+
./gradlew publish \
166166
-DARTEFACT_VERSION=$ARTEFACT_VERSION \
167167
-DGITHUB_REPOSITORY=${{ github.repository }} \
168168
-DGITHUB_ACTOR=${{ github.actor }} \
@@ -258,8 +258,9 @@ jobs:
258258
done
259259
260260
# Run tests (containers already running via docker compose)
261-
gradle testClasses
262-
gradle --no-daemon test --tests "*"
261+
# Skip composeUp and composeDown since we manage containers manually
262+
../gradlew testClasses
263+
../gradlew --no-daemon test -x composeUp -x composeDown
263264
264265
# Clean up containers manually
265266
docker compose down

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- name: Gradle Build
5050
run: |
51-
gradle build cyclonedxBom -x test
51+
./gradlew build cyclonedxBom -x test
5252
5353
# ℹ️ Command-line programs to run using the OS shell.
5454
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -89,7 +89,7 @@ jobs:
8989
gradle-version: current
9090

9191
- name: Gradle Build
92-
run: gradle build -x test
92+
run: ./gradlew build -x test
9393

9494
- name: Set up Docker Buildx
9595
uses: docker/setup-buildx-action@v3

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
gradle/wrapper
21
bin/*
32
!bin/run-in-docker.sh
43
.gradle
54
/build/
6-
/gradlew
75
/gradlew.bat
86
!gradle/wrapper/gradle-wrapper.properties
97
*.class

apiTest/apiTest_README.md

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,22 @@ Before running the tests, ensure you have the following installed and configured
4040
cd apiTest
4141

4242
# Run all tests
43-
gradle test
43+
../gradlew test
4444

4545
# Run tests with more verbose output
46-
gradle test --info
46+
../gradlew test --info
4747

4848
# Run tests with debug output
49-
gradle test --debug
49+
../gradlew test --debug
5050
```
5151

5252
### From the apiTest Directory
5353

5454
```bash
55-
# If you're already in the apiTest directory
56-
gradle test
55+
# If you're already in the apiTest directory, you can use either:
56+
./gradlew test # Uses apiTest's own Gradle wrapper
57+
# or
58+
../gradlew test # Uses root project's Gradle wrapper
5759
```
5860

5961
### What Happens When You Run Tests
@@ -71,10 +73,10 @@ gradle test
7173

7274
```bash
7375
# Run a specific test class
74-
gradle test --tests "RootApiTest"
76+
../gradlew test --tests "RootApiTest"
7577

7678
# Run a specific test method
77-
gradle test --tests "RootApiTest.root_endpoint_should_be_ok"
79+
../gradlew test --tests "RootApiTest.root_endpoint_should_be_ok"
7880
```
7981

8082
## Test Reports
@@ -102,15 +104,15 @@ These XML reports are useful for CI/CD integration.
102104
### Issue: "Could not start Gradle Test Executor 1: Failed to load JUnit Platform"
103105

104106
**Solution:** This should be resolved with the current configuration. If you see this error:
105-
1. Clean the build: `gradle clean`
106-
2. Rebuild: `gradle build`
107+
1. Clean the build: `../gradlew clean`
108+
2. Rebuild: `../gradlew build`
107109

108110
### Issue: "no main manifest attribute, in /app/apiTest-0.0.999.jar"
109111

110112
**Solution:** This means the Docker build context is wrong. Ensure:
111113
1. The `docker-compose.yml` has `context: ..` (builds from root directory)
112114
2. The root project's `bootJar` is built before Docker build
113-
3. Run: `gradle buildRootBootJar` manually if needed
115+
3. Run: `../gradlew buildRootBootJar` manually if needed
114116

115117
### Issue: Container exits with code 1
116118

@@ -152,26 +154,6 @@ lsof -i :5432
152154
- Check database logs: `docker-compose -f docker-compose.yml logs db`
153155
- Verify connection string in `docker-compose.yml` matches database configuration
154156

155-
## Manual Container Management
156-
157-
If you need to manually manage containers:
158-
159-
```bash
160-
# Start containers without running tests
161-
docker-compose -f docker-compose.yml up -d
162-
163-
# Stop containers
164-
docker-compose -f docker-compose.yml down
165-
166-
# View container logs
167-
docker-compose -f docker-compose.yml logs -f app
168-
169-
# Check container status
170-
docker-compose -f docker-compose.yml ps
171-
172-
# Rebuild containers
173-
docker-compose -f docker-compose.yml build --no-cache
174-
```
175157

176158
## Test Configuration
177159

@@ -186,6 +168,6 @@ Tests use the following default configuration:
186168

187169
You can override the application URL:
188170
```bash
189-
gradle test -Dapp.baseUrl=http://localhost:8080
171+
../gradlew test -Dapp.baseUrl=http://localhost:8080
190172
```
191173

apiTest/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ dockerCompose {
7979
tasks.register('buildRootBootJar', Exec) {
8080
description = "Builds the root project's bootJar"
8181
workingDir = projectDir.parent
82-
executable = "gradle"
82+
executable = "./gradlew"
8383
args = ['bootJar']
8484
}
8585

44.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

gradle/wrapper/gradle-wrapper.jar

44.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)