Skip to content

Commit 8cdfccd

Browse files
proubatsisgkwan-ibm
authored andcommitted
Fix broken guide (#36)
* Fix maven-ear-plugin module URIs * Move aggregating build section * Re-arrange flow of the guide * Fix filepaths * Make "start/" consistent with "start" * Add .gitkeep file for server config directory * Replace Test.java with .gitkeep * Re-arrange "mvn install" instructions * Add hotspots for "jar", "war", and "ear" * Make tags in README self-closing * Remove sentence Andrew mentioned it
1 parent 019f168 commit 8cdfccd

File tree

5 files changed

+73
-130
lines changed

5 files changed

+73
-130
lines changed

README.adoc

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ You will learn how to establish a dependency between a web module and a Java lib
3535

3636
You will build a unit converter application that converts heights from centimeters into feet and inches. Enter heights in centimeters from a web page, and the application processes the input with functions in the JAR file to return the corresponding height in Imperial units.
3737

38-
When the application is running, you can access the unit converter at the following location: http://localhost:9080/converter[http://localhost:9080/converter^]
39-
40-
4138

4239
// =================================================================================================
4340
// Getting Started
@@ -52,9 +49,9 @@ Access partial implementation of the application from the `start` folder. This f
5249

5350
2. Assemble the entire application into an EAR file.
5451

55-
3. Test the multi-module application.
52+
3. Aggregate the entire build.
5653

57-
4. Aggregate the entire build.
54+
4. Test the multi-module application.
5855

5956

6057
// =================================================================================================
@@ -123,7 +120,7 @@ Set the [hotspot=7-11 file=0]`basic configuration` for the project and set the [
123120

124121
The [hotspot=16-21 file=0]`Java library module` and the [hotspot=22-27 file=0]`web module` were added as dependencies. Specify [hotspot=26 file=0]`<type>war</type>` for the web module. If you don’t specify the web module, Maven looks for a JAR file.
125122

126-
The definition and configuration of the [hotspot=38-58 file=0]`maven-ear-plugin` plug-in were added to create an EAR file. Define the [hotspot=44-48 file=0]`<jarModule>` and [hotspot=49-55 file=0]`<webModule>` modules to be packaged into the EAR file.
123+
The definition and configuration of the [hotspot=38-58 file=0]`maven-ear-plugin` plug-in were added to create an EAR file. Define the [hotspot=44-48 file=0]`<jarModule/>` and [hotspot=49-55 file=0]`<webModule/>` modules to be packaged into the EAR file.
127124
To customize the context root of the application, set the appropriate contextRoot in the webModule. Otherwise, Maven automatically uses the WAR file `artifactId` ID as the context root for the application while generating the `application.xml` file.
128125

129126
To download and start an Open Liberty server, use the [hotspot=61-90 file=0]`liberty-maven-plugin` plug-in for Maven. This configuration is provided, and the executions of the plug-in follow the typical phases of a Maven life cycle.
@@ -141,21 +138,84 @@ server.xml
141138
include::finish/ear/src/main/liberty/config/server.xml[tags=**]
142139
----
143140

141+
// =================================================================================================
142+
// Aggregating the entire build
143+
// =================================================================================================
144+
145+
== Aggregating the entire build
146+
147+
Because you have multiple modules, aggregate the Maven projects to simplify the build process.
148+
149+
Create a parent `pom.xml` file under the `start` directory to link all of the child modules together. A template is provided for you.
150+
151+
[role="code_command hotspot", subs="quotes"]
152+
----
153+
#Replace the start/POM file.#
154+
`pom.xml`
155+
----
156+
start/pom.xml
157+
[source, xml, linenums, role='code_column']
158+
----
159+
include::finish/pom.xml[tags=**]
160+
----
161+
Set the [hotspot=13-17 file=0]`basic configuration` for the project. Set `pom` as the [hotspot=17 file=0]`<packaging/>` element of the parent `pom.xml` file. Specify `io.openliberty.guides` as the [hotspot=14 file=0]`<groupId/>` ID, which the child `pom.xml` files will inherit.
162+
163+
In the parent `pom.xml` file, list all of the [hotspot=19-23 file=0]`<modules/>` that you want to aggregate for the application.
164+
165+
Lastly,
166+
167+
[role="code_command hotspot", subs="quotes"]
168+
----
169+
#Update the `pom.xml` in the child module `jar`, `war` and `ear` projects.#
170+
`jar/pom.xml`
171+
`war/pom.xml`
172+
`ear/pom.xml`
173+
----
174+
175+
[role="edit_command_text"]
176+
Add a [hotspot=1-5 file=1]`<parent/>` section just above `basic configuration` to each of the `pom.xml` files in the child modules,
177+
such as the [hotspot=9-13 file=2]`jar`, [hotspot=14-19 file=3]`war`, and [hotspot=13-17 file=4]`ear` projects.
178+
179+
pom.xml
180+
[source, xml, linenums, role='code_column']
181+
----
182+
include::finish/ear/pom.xml[tags=parent]
183+
----
184+
185+
jar/pom.xml
186+
[source, xml, linenums, role='code_column']
187+
----
188+
include::finish/jar/pom.xml[tags=**]
189+
----
190+
191+
war/pom.xml
192+
[source, xml, linenums, role='code_column']
193+
----
194+
include::finish/war/pom.xml[tags=**]
195+
----
196+
197+
ear/pom.xml
198+
[source, xml, linenums, role='code_column']
199+
----
200+
include::finish/ear/pom.xml[tags=**]
201+
----
202+
144203
// =================================================================================================
145204
// Building the modules
146205
// =================================================================================================
147206

148207
== Building the modules
149208

150-
To build the three modules, run the following commands from the `jar` directory, `war` directory, and `ear` directory in that order. Start with the `jar` directory, proceed to the `war` directory, and end with the `ear` directory.
209+
This command creates a JAR file in the `jar/target` directory, a WAR file in the `war/target` directory, and an EAR file in the `ear/target` directory, which contains the JAR and WAR files.
210+
211+
By aggregating the build in the previous section, you can run `mvn install` once from the `start` directory and it will automatically build all your modules. Use the following command to build the entire application from the `start` directory:
151212

152213
[role=command]
153214
----
154215
mvn install
155216
----
156217

157-
These commands create a JAR file in the `jar/target` directory, a WAR file in the `war/target` directory, and an EAR file in the `ear/target` directory, which contains the JAR and WAR files.
158-
218+
Since the modules are independent, you can re-build them individually by running `mvn install` from the corresponding module directory.
159219

160220
// =================================================================================================
161221
// Starting the application
@@ -191,7 +251,7 @@ To test the multi-module application, add integration tests to the EAR project.
191251
[role="code_command hotspot", subs="quotes"]
192252
----
193253
#Create the `Test` class.#
194-
`start/ear/src/test/java/it/io/openliberty/guides/multimodules/Test.java`
254+
`ear/src/test/java/it/io/openliberty/guides/multimodules/Test.java`
195255
----
196256
Test.java
197257
[source, Java, linenums, role='code_column']
@@ -230,68 +290,6 @@ Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
230290
231291
----
232292

233-
234-
// =================================================================================================
235-
// Aggregating the entire build
236-
// =================================================================================================
237-
238-
== Aggregating the entire build
239-
240-
Because you have multiple modules, aggregate the Maven projects to simplify the build process.
241-
242-
Create a parent `pom.xml` file under the `start` directory to link all of the child modules together. A template is provided for you.
243-
244-
[role="code_command hotspot", subs="quotes"]
245-
----
246-
#Replace the start/POM file.#
247-
`start/pom.xml`
248-
----
249-
start/pom.xml
250-
[source, xml, linenums, role='code_column']
251-
----
252-
include::finish/pom.xml[tags=**]
253-
----
254-
Set the [hotspot=13-17 file=0]`basic configuration` for the project. Set `pom` as the [hotspot=17 file=0]`<packaging/>` element of the parent `pom.xml` file. Specify `io.openliberty.guides` as the [hotspot=14 file=0]`<groupId/>` ID, which the child `pom.xml` files will inherit.
255-
256-
In the parent `pom.xml` file, list all of the [hotspot=19-23 file=0]`<modules/>` that you want to aggregate for the application.
257-
258-
Lastly,
259-
260-
[role="code_command hotspot", subs="quotes"]
261-
----
262-
#Update the `pom.xml` in the child module `jar`, `war` and `ear` projects.#
263-
`jar/pom.xml`
264-
`war/pom.xml`
265-
`ear/pom.xml`
266-
----
267-
268-
[role="edit_command_text"]
269-
Add a [hotspot=1-5]`<parent/>` section just above `basic configuration` to each of the `pom.xml` files in the child modules,
270-
such as the `jar`, `war`, and `ear` projects.
271-
272-
pom.xml
273-
[source, xml, linenums, role='code_column']
274-
----
275-
include::finish/ear/pom.xml[tags=parent]
276-
----
277-
278-
279-
// =================================================================================================
280-
// Building the application
281-
// =================================================================================================
282-
283-
== Building the application
284-
285-
Use the following command to build the entire application from the `start` directory:
286-
287-
[role=command]
288-
----
289-
mvn install
290-
----
291-
292-
You no longer need to execute multiple `mvn install` commands from different directories. With a single command, you can build and test the whole application and all of the modules.
293-
294-
295293
// =================================================================================================
296294
// Congratulations! You're done!
297295
// =================================================================================================

finish/ear/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
<jarModule>
5757
<groupId>io.openliberty.guides</groupId>
5858
<artifactId>io.openliberty.guides.multimodules.jar</artifactId>
59-
<uri>io.openliberty.guides.multimodules.jar-0.0.1-SNAPSHOT.jar</uri>
59+
<uri>/io.openliberty.guides.multimodules.jar-0.0.1-SNAPSHOT.jar</uri>
6060
</jarModule>
6161
<webModule>
6262
<groupId>io.openliberty.guides</groupId>
6363
<artifactId>io.openliberty.guides.multimodules.war</artifactId>
64-
<uri>io.openliberty.guides.multimodules.war-0.0.1-SNAPSHOT.war</uri>
64+
<uri>/io.openliberty.guides.multimodules.war-0.0.1-SNAPSHOT.war</uri>
6565
<!-- Set custom context root -->
6666
<contextRoot>/converter</contextRoot>
6767
</webModule>
@@ -157,4 +157,4 @@
157157
</plugins>
158158
</build>
159159

160-
</project>
160+
</project>

start/ear/src/main/liberty/config/.gitkeep

Whitespace-only changes.

start/ear/src/test/java/it/io/openliberty/guides/multimodules/.gitkeep

Whitespace-only changes.

start/ear/src/test/java/it/io/openliberty/guides/multimodules/Test.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)