Skip to content

Commit 33edad5

Browse files
gkwan-ibmdev-koan
andauthored
update to use maven wrapper (#232)
* update to use maven wrapper Signed-off-by: Gilbert Kwan <[email protected]> * update to use maven wrapper Signed-off-by: Gilbert Kwan <[email protected]> * update to use maven wrapper Signed-off-by: Gilbert Kwan <[email protected]> * update to use maven wrapper Signed-off-by: Gilbert Kwan <[email protected]> * update to use maven wrapper Signed-off-by: Gilbert Kwan <[email protected]> * update to use maven wrapper Signed-off-by: Gilbert Kwan <[email protected]> * Update README.adoc * Update README to use Usage: docker compose [OPTIONS] COMMAND Define and run multi-container applications with Docker Options: --all-resources Include all resources, even those not used by services --ansi string Control when to print ANSI control characters ("never"|"always"|"auto") (default "auto") --compatibility Run compose in backward compatibility mode --dry-run Execute command in dry run mode --env-file stringArray Specify an alternate environment file -f, --file stringArray Compose configuration files --parallel int Control max parallelism, -1 for unlimited (default -1) --profile stringArray Specify a profile to enable --progress string Set type of progress output (auto, tty, plain, json, quiet) (default "auto") --project-directory string Specify an alternate working directory (default: the path of the, first specified, Compose file) -p, --project-name string Project name Commands: attach Attach local standard input, output, and error streams to a service's running container build Build or rebuild services commit Create a new image from a service container's changes config Parse, resolve and render compose file in canonical format cp Copy files/folders between a service container and the local filesystem create Creates containers for a service down Stop and remove containers, networks events Receive real time events from containers exec Execute a command in a running container export Export a service container's filesystem as a tar archive images List images used by the created containers kill Force stop service containers logs View output from containers ls List running compose projects pause Pause services port Print the public port for a port binding ps List containers pull Pull service images push Push service images restart Restart service containers rm Removes stopped service containers run Run a one-off command on a service scale Scale services start Start services stats Display a live stream of container(s) resource usage statistics stop Stop services top Display the running processes unpause Unpause services up Create and start containers version Show the Docker Compose version information wait Block until containers of all (or specified) services stop. watch Watch build context for service and rebuild/refresh containers when files are updated Run 'docker compose COMMAND --help' for more information on a command. Signed-off-by: Dev Agarwal <[email protected]> * Update README.adoc --------- Signed-off-by: Gilbert Kwan <[email protected]> Signed-off-by: Dev Agarwal <[email protected]> Co-authored-by: Dev Agarwal <[email protected]>
1 parent 449c763 commit 33edad5

File tree

11 files changed

+1188
-34
lines changed

11 files changed

+1188
-34
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
VALIDATE_ALL_CODEBASE: false
2929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
LINTER_RULES_PATH: ./tools/pr-checker/linters/
31+
FILTER_REGEX_EXCLUDE: mvnw*
3132
DEFAULT_BRANCH: prod
3233
- name: Summary
3334
if: "! github.event.pull_request.head.repo.fork"

README.adoc

Lines changed: 95 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ include::{common-includes}/gitclone.adoc[]
6767
Run the following command to start the Pact Broker:
6868
[role='command']
6969
```
70-
docker-compose -f "pact-broker/docker-compose.yml" up -d --build
70+
docker compose -f "pact-broker/docker-compose.yml" up -d --build
7171
```
7272

7373
When the Pact Broker is running, you'll see the following output:
@@ -100,24 +100,51 @@ You can refer to the https://docs.pact.io/pact_broker/docker_images/pactfoundati
100100

101101
== Implementing pact testing in the inventory service
102102

103-
Navigate to the `start/inventory` directory to begin.
103+
Navigate to the `start` directory to begin.
104104

105105
ifdef::cloud-hosted[]
106106
```bash
107-
cd /home/project/guide-contract-testing/start/inventory
107+
cd /home/project/guide-contract-testing/start
108108
```
109109
endif::[]
110110

111-
[role=command]
112-
include::{common-includes}/devmode-lmp33-start.adoc[]
111+
When you run Open Liberty in https://openliberty.io/docs/latest/development-mode.html[dev mode^], dev mode listens for file changes and automatically recompiles and deploys your updates whenever you save a new change. Run the following goal to start Open Liberty in dev mode:
113112

114-
ifndef::cloud-hosted[]
115-
Navigate back to the `start` directory.
116-
endif::[]
113+
include::{common-includes}/os-tabs.adoc[]
117114

118-
ifdef::cloud-hosted[]
119-
Open a new command-line session.
120-
endif::[]
115+
[.tab_content.windows_section]
116+
--
117+
[role='command']
118+
```
119+
mvnw.cmd -f inventory\pom.xml liberty:dev
120+
```
121+
--
122+
123+
[.tab_content.mac_section]
124+
--
125+
[role='command']
126+
```
127+
./mvnw -f inventory/pom.xml liberty:dev
128+
```
129+
--
130+
131+
[.tab_content.linux_section]
132+
--
133+
[role='command']
134+
```
135+
./mvnw -f inventory/pom.xml liberty:dev
136+
```
137+
--
138+
139+
After you see the following message, your Liberty instance is ready in dev mode:
140+
141+
[role="no_copy"]
142+
----
143+
**************************************************************
144+
* Liberty is running in dev mode.
145+
----
146+
147+
Dev mode holds your command-line session to listen for file changes. Open another command-line session to continue, or open the project in your editor.
121148

122149
[role="code_command hotspot file=0", subs="quotes"]
123150
----
@@ -149,7 +176,7 @@ inventory/pom.xml
149176
include::finish/inventory/pom.xml[]
150177
----
151178

152-
The Pact framework provides a [hotspot=pactPlugin file=1]`Maven` plugin that can be added to the build section of the `pom.xml` file. The [hotspot=serviceProvider file=1]`serviceProvider` element defines the endpoint URL for the `system` microservice and the [hotspot=pactDirectory file=1]`pactFileDirectory` directory where you want to store the pact file. The [hotspot=pactJunit file=1]`pact-jvm-consumer-junit` dependency provides the base test class that you can use with JUnit to build unit tests.
179+
The Pact framework provides a [hotspot=pactPlugin file=1]`maven` plugin that can be added to the build section of the `pom.xml` file. The [hotspot=serviceProvider file=1]`serviceProvider` element defines the endpoint URL for the `system` microservice and the [hotspot=pactDirectory file=1]`pactFileDirectory` directory where you want to store the pact file. The [hotspot=pactJunit file=1]`pact-jvm-consumer-junit` dependency provides the base test class that you can use with JUnit to build unit tests.
153180

154181
After you create the `InventoryPactIT.java` class and replace the `pom.xml` file, Open Liberty automatically reloads its configuration.
155182

@@ -171,7 +198,7 @@ When completed, you'll see a similar output to the following example:
171198
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
172199
```
173200

174-
When you integrate the Pact framework in a CI/CD build pipeline, you can use the `mvn failsafe:integration-test` goal to generate the pact file. The Maven failsafe plug-in provides a lifecycle phase for running integration tests that run after unit tests. By default, it looks for classes that are suffixed with `IT`, which stands for Integration Test. You can refer to the https://maven.apache.org/surefire/maven-failsafe-plugin/[Maven failsafe plug-in documentation^] for more information.
201+
When you integrate the Pact framework in a CI/CD build pipeline, you can use the Maven `failsafe:integration-test` goal to generate the pact file. The Maven `failsafe` plug-in provides a lifecycle phase for running integration tests that run after unit tests. By default, it looks for classes that are suffixed with `IT`, which stands for Integration Test. You can refer to the https://maven.apache.org/surefire/maven-failsafe-plugin/[Maven failsafe plug-in documentation^] for more information.
175202

176203
The generated pact file is named `Inventory-System.json` and is located in the `inventory/target/pacts` directory. The pact file contains the defined interactions in JSON format:
177204

@@ -209,22 +236,44 @@ The generated pact file is named `Inventory-System.json` and is located in the `
209236
----
210237

211238
ifndef::cloud-hosted[]
212-
Now, navigate to the `start/inventory` directory again.
239+
Now, navigate to the `start` directory again.
213240
endif::[]
214241

215242
ifdef::cloud-hosted[]
216-
Open a new command-line session and navigate to the `start/inventory` directory.
243+
Open a new command-line session and navigate to the `start` directory.
217244

218245
```bash
219-
cd /home/project/guide-contract-testing/start/inventory
246+
cd /home/project/guide-contract-testing/start
220247
```
221248
endif::[]
222249

223250
Publish the generated pact file to the Pact Broker by running the following command:
251+
252+
include::{common-includes}/os-tabs.adoc[]
253+
254+
[.tab_content.windows_section]
255+
--
256+
[role='command']
257+
```
258+
mvnw.cmd -f inventory\pom.xml pact:publish
259+
```
260+
--
261+
262+
[.tab_content.mac_section]
263+
--
264+
[role='command']
265+
```
266+
./mvnw -f inventory/pom.xml pact:publish
267+
```
268+
--
269+
270+
[.tab_content.linux_section]
271+
--
224272
[role='command']
225273
```
226-
mvn pact:publish
274+
./mvnw -f inventory/pom.xml pact:publish
227275
```
276+
--
228277

229278
After the file is published, you'll see a similar output to the following example:
230279
[role="no_copy"]
@@ -272,19 +321,41 @@ image::pact-broker-interactions.png[Pact Broker webpage for Interactions,width=9
272321
== Implementing pact testing in the system service
273322

274323

275-
Open another command-line session and navigate to the `start/system` directory.
324+
Open another command-line session and navigate to the `start` directory.
276325

277326
ifdef::cloud-hosted[]
278327
```bash
279-
cd /home/project/guide-contract-testing/start/system
328+
cd /home/project/guide-contract-testing/start
280329
```
281330
endif::[]
282331

283332
Start Open Liberty in dev mode for the `system` microservice:
284-
[role=command]
333+
334+
include::{common-includes}/os-tabs.adoc[]
335+
336+
[.tab_content.windows_section]
337+
--
338+
[role='command']
339+
```
340+
mvnw.cmd -f system\pom.xml liberty:dev
341+
```
342+
--
343+
344+
[.tab_content.mac_section]
345+
--
346+
[role='command']
347+
```
348+
./mvnw -f system/pom.xml liberty:dev
349+
```
350+
--
351+
352+
[.tab_content.linux_section]
353+
--
354+
[role='command']
285355
```
286-
mvn liberty:dev
356+
./mvnw -f system/pom.xml liberty:dev
287357
```
358+
--
288359

289360
After you see the following message, your Liberty instance is ready in dev mode:
290361

@@ -296,7 +367,7 @@ After you see the following message, your Liberty instance is ready in dev mode:
296367
{empty} +
297368

298369
ifndef::cloud-hosted[]
299-
Open another command-line session and navigate back to the `start` directory to continue.
370+
Open another command-line session and navigate to the `start` directory to continue.
300371
endif::[]
301372

302373
ifdef::cloud-hosted[]
@@ -347,7 +418,7 @@ After you create the `SystemBrokerIT.java` class and replace the `pom.xml` file,
347418

348419
== Verifying the contract
349420

350-
In the command-line session where you started the `system` microservice, press the `enter/return` key to run the tests to verify the pact file. When you integrate the Pact framework into a CI/CD build pipeline, you can use the `mvn failsafe:integration-test` goal to verify the pact file from the Pact Broker.
421+
In the command-line session where you started the `system` microservice, press the `enter/return` key to run the tests to verify the pact file. When you integrate the Pact framework into a CI/CD build pipeline, you can use the Maven `failsafe:integration-test` goal to verify the pact file from the Pact Broker.
351422

352423
The tests fail with the following errors:
353424
[role="no_copy"]
@@ -436,7 +507,7 @@ endif::[]
436507

437508
[role='command']
438509
```
439-
docker-compose -f "pact-broker/docker-compose.yml" down
510+
docker compose -f "pact-broker/docker-compose.yml" down
440511
docker rmi postgres:17.2
441512
docker rmi pactfoundation/pact-broker:latest
442513
docker volume rm pact-broker_postgres-volume
61.6 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar

0 commit comments

Comments
 (0)