Quellcode durchsuchen

Convert guide to display both Gradle and Maven info

Greg Turnquist vor 13 Jahren
Ursprung
Commit
6d3b044419
2 geänderte Dateien mit 20 neuen und 6 gelöschten Zeilen
  1. 3
    4
      README.ftl.md
  2. 17
    2
      README.md

+ 3
- 4
README.ftl.md Datei anzeigen

@@ -45,9 +45,8 @@ Set up the project
45 45
 
46 46
 <@create_directory_structure_hello/>
47 47
 
48
-### Create a Gradle build file
49 48
 
50
-    <@snippet path="build.gradle" prefix="initial"/>
49
+<@create_both_builds/>
51 50
 
52 51
 <@bootstrap_starter_pom_disclaimer/>
53 52
 
@@ -121,9 +120,9 @@ The [`@EnableAutoConfiguration`][] annotation switches on reasonable default beh
121 120
 
122 121
 <@build_an_executable_jar_subhead/>
123 122
 
124
-<@build_an_executable_jar_with_gradle/>
123
+<@build_an_executable_jar_with_both/>
125 124
 
126
-<@run_the_application_with_gradle module="service"/>
125
+<@run_the_application_with_both module="service"/>
127 126
 
128 127
 Logging output is displayed. The service should be up and running within a few seconds.
129 128
 

+ 17
- 2
README.md Datei anzeigen

@@ -71,7 +71,9 @@ In a project directory of your choosing, create the following subdirectory struc
71 71
             └── java
72 72
                 └── hello
73 73
 
74
+
74 75
 ### Create a Gradle build file
76
+Below is the [initial Gradle build file](https://github.com/springframework-meta/gs-rest-service/blob/master/initial/build.gradle). But you can also use Maven. The pom.xml file is included [right here](https://github.com/springframework-meta/gs-rest-service/blob/master/initial/pom.xml).
75 77
 
76 78
 `build.gradle`
77 79
 ```gradle
@@ -106,6 +108,8 @@ task wrapper(type: Wrapper) {
106 108
     gradleVersion = '1.7'
107 109
 }
108 110
 ```
111
+    
112
+    
109 113
 
110 114
 This guide is using [Spring Boot's starter POMs](/guides/gs/spring-boot/).
111 115
 
@@ -242,6 +246,8 @@ The [`@EnableAutoConfiguration`][] annotation switches on reasonable default beh
242 246
 
243 247
 Now that your `Application` class is ready, you simply instruct the build system to create a single, executable jar containing everything. This makes it easy to ship, version, and deploy the service as an application throughout the development lifecycle, across different environments, and so forth.
244 248
 
249
+Below are the Gradle steps, but if you are using Maven, you can find the updated pom.xml [right here](https://github.com/springframework-meta/gs-rest-service/blob/master/complete/pom.xml) and build it by typing `mvn clean package`.
250
+
245 251
 Update your Gradle `build.gradle` file's `buildscript` section, so that it looks like this:
246 252
 
247 253
 ```groovy
@@ -261,6 +267,7 @@ Further down inside `build.gradle`, add the following to the list of applied plu
261 267
 ```groovy
262 268
 apply plugin: 'spring-boot'
263 269
 ```
270
+You can see the final version of `build.gradle` [right here]((https://github.com/springframework-meta/gs-rest-service/blob/master/complete/build.gradle).
264 271
 
265 272
 The [Spring Boot gradle plugin][spring-boot-gradle-plugin] collects all the jars on the classpath and builds a single "über-jar", which makes it more convenient to execute and transport your service.
266 273
 It also searches for the `public static void main()` method to flag as a runnable class.
@@ -271,24 +278,32 @@ Now run the following command to produce a single executable JAR file containing
271 278
 $ ./gradlew build
272 279
 ```
273 280
 
274
-Now you can run the JAR by typing:
281
+If you are using Gradle, you can run the JAR by typing:
275 282
 
276 283
 ```sh
277 284
 $ java -jar build/libs/gs-rest-service-0.1.0.jar
278 285
 ```
279 286
 
287
+If you are using Maven, you can run the JAR by typing:
288
+
289
+```sh
290
+$ java -jar target/gs-rest-service-0.1.0.jar
291
+```
292
+
280 293
 [spring-boot-gradle-plugin]: https://github.com/SpringSource/spring-boot/tree/master/spring-boot-tools/spring-boot-gradle-plugin
281 294
 
282 295
 > **Note:** The procedure above will create a runnable JAR. You can also opt to [build a classic WAR file](/guides/gs/convert-jar-to-war/) instead.
283 296
 
284 297
 Run the service
285 298
 -------------------
286
-Run your service at the command line:
299
+If you are using Gradle, you can run your service at the command line this way:
287 300
 
288 301
 ```sh
289 302
 $ ./gradlew clean build && java -jar build/libs/gs-rest-service-0.1.0.jar
290 303
 ```
291 304
 
305
+> **Note:** If you are using Maven, you can run your service by typing `mvn clean package && java -jar target/gs-rest-service-0.1.0.jar`.
306
+
292 307
 
293 308
 Logging output is displayed. The service should be up and running within a few seconds.
294 309