diff --git a/README.ftl.md b/README.ftl.md index 010531b874..d90420d23d 100644 --- a/README.ftl.md +++ b/README.ftl.md @@ -23,9 +23,8 @@ Set up the project <@create_directory_structure_hello/> -### Create a Gradle build file - <@snippet path="build.gradle" prefix="initial"/> +<@create_both_builds/> <@bootstrap_starter_pom_disclaimer/> @@ -119,9 +118,9 @@ For demonstration purposes, there is code to create a `JdbcTemplate`, query the <@build_an_executable_jar_subhead/> -<@build_an_executable_jar_with_gradle/> +<@build_an_executable_jar_with_both/> -<@run_the_application_with_gradle module="batch job"/> +<@run_the_application_with_both module="batch job"/> The job prints out a line for each person that gets transformed. After the job runs, you can also see the output from querying the database. diff --git a/README.md b/README.md index 5759f0b963..d18b59b586 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,9 @@ In a project directory of your choosing, create the following subdirectory struc └── java └── hello + ### Create a Gradle build file +Below is the [initial Gradle build file](https://github.com/springframework-meta/gs-batch-processing/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-batch-processing/blob/master/initial/pom.xml). `build.gradle` ```gradle @@ -86,6 +88,8 @@ task wrapper(type: Wrapper) { gradleVersion = '1.7' } ``` + + This guide is using [Spring Boot's starter POMs](/guides/gs/spring-boot/). @@ -428,6 +432,8 @@ For demonstration purposes, there is code to create a `JdbcTemplate`, query the 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. +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-batch-processing/blob/master/complete/pom.xml) and build it by typing `mvn clean package`. + Update your Gradle `build.gradle` file's `buildscript` section, so that it looks like this: ```groovy @@ -447,6 +453,7 @@ Further down inside `build.gradle`, add the following to the list of applied plu ```groovy apply plugin: 'spring-boot' ``` +You can see the final version of `build.gradle` [right here]((https://github.com/springframework-meta/gs-batch-processing/blob/master/complete/build.gradle). 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. It also searches for the `public static void main()` method to flag as a runnable class. @@ -457,24 +464,32 @@ Now run the following command to produce a single executable JAR file containing $ ./gradlew build ``` -Now you can run the JAR by typing: +If you are using Gradle, you can run the JAR by typing: ```sh $ java -jar build/libs/gs-batch-processing-0.1.0.jar ``` +If you are using Maven, you can run the JAR by typing: + +```sh +$ java -jar target/gs-batch-processing-0.1.0.jar +``` + [spring-boot-gradle-plugin]: https://github.com/SpringSource/spring-boot/tree/master/spring-boot-tools/spring-boot-gradle-plugin > **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. Run the batch job ------------------- -Run your batch job at the command line: +If you are using Gradle, you can run your batch job at the command line this way: ```sh $ ./gradlew clean build && java -jar build/libs/gs-batch-processing-0.1.0.jar ``` +> **Note:** If you are using Maven, you can run your batch job by typing `mvn clean package && java -jar target/gs-batch-processing-0.1.0.jar`. + The job prints out a line for each person that gets transformed. After the job runs, you can also see the output from querying the database.