diff --git a/spring-boot-samples/spring-boot-sample-actuator/README.md b/spring-boot-samples/spring-boot-sample-actuator/README.md new file mode 100644 index 00000000000..5818a1e87ec --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-actuator/README.md @@ -0,0 +1,21 @@ +# Spring Boot Actuator Sample + +You can build this sample using Maven (>3) or Gradle (1.6). + +With Maven: + +``` +$ mvn package +$ java -jar target/*.jar +``` + +Then access the app via a browser (or curl) on http://localhost:8080 (the user name is "user" and look at the INFO log output for the password to login). + +With gradle: + +``` +$ gradle build +$ java -jar build/libs/*.jar +``` + +The gradle build contains an intentionally odd configuration to exclude the security dependencies from the executable JAR. So the app run like this behaves differently than the one run from the Maven-built JAR file. See comments in the `build.gradle` for details. \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-actuator/build.gradle b/spring-boot-samples/spring-boot-sample-actuator/build.gradle new file mode 100644 index 00000000000..ba3aacfe664 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-actuator/build.gradle @@ -0,0 +1,49 @@ +buildscript { + repositories { + mavenLocal() + maven { url "http://repo.springsource.org/libs-snapshot" } + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.BUILD-SNAPSHOT") + } +} + +ext { + springBootVersion = '0.5.0.BUILD-SNAPSHOT' +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' +apply plugin: 'spring-boot' + +jar { + baseName = 'spring-boot-sample-actuator' + version = '0.5.0' +} + +repositories { + mavenCentral() + maven { url "http://repo.springsource.org/libs-snapshot" } +} + +dependencies { + configurations { + insecure.exclude module: 'spring-boot-starter-security' + } + compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") + compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}") + compile("org.springframework.boot:spring-boot-starter-security:${springBootVersion}") + testCompile("junit:junit:4.11") + insecure configurations.runtime +} + +// Slightly odd requirement (package a jar file as an insecure app, exlcuding Spring Security) +// just to demonstrate the "customConfiguration" feature of the Boot gradle plugin. +springBoot { + customConfiguration = "insecure" +} + +task wrapper(type: Wrapper) { + gradleVersion = '1.6' +} diff --git a/spring-boot-samples/spring-boot-sample-simple/README.md b/spring-boot-samples/spring-boot-sample-simple/README.md new file mode 100644 index 00000000000..8fefef0525d --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-simple/README.md @@ -0,0 +1,19 @@ +# Spring Boot Simple Sample + +You can build this sample using Maven (>3) or Gradle (1.6). + +With Maven: + +``` +$ mvn package +$ java -jar target/*.jar +``` + +The app prints a Hello message on the console. + +With gradle: + +``` +$ gradle build +$ java -jar build/libs/*.jar +``` diff --git a/spring-boot-samples/spring-boot-sample-simple/build.gradle b/spring-boot-samples/spring-boot-sample-simple/build.gradle new file mode 100644 index 00000000000..ad85b45738b --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-simple/build.gradle @@ -0,0 +1,37 @@ +buildscript { + repositories { + mavenLocal() + maven { url "http://repo.springsource.org/libs-snapshot" } + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.BUILD-SNAPSHOT") + } +} + +ext { + springBootVersion = '0.5.0.BUILD-SNAPSHOT' +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' +apply plugin: 'spring-boot' + +jar { + baseName = 'spring-boot-sample-simple' + version = '0.5.0' +} + +repositories { + mavenCentral() + maven { url "http://repo.springsource.org/libs-snapshot" } +} + +dependencies { + compile("org.springframework.boot:spring-boot-starter:${springBootVersion}") + testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}") +} + +task wrapper(type: Wrapper) { + gradleVersion = '1.6' +} diff --git a/spring-boot-tools/spring-boot-gradle-plugin/README.md b/spring-boot-tools/spring-boot-gradle-plugin/README.md index ed4efbef022..0affe950e73 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/README.md +++ b/spring-boot-tools/spring-boot-gradle-plugin/README.md @@ -44,6 +44,13 @@ $ gradle build $ java -jar build/libs/mymodule-0.0.1-SNAPSHOT.jar ``` +### Running a Project in Place + +To run a project in place without building a jar first you can use the "bootRun" task: + +``` +$ gradle bootRun +``` ### Repackage configuration The gradle plugin automatically extends your build script DSL with a `springBoot` element diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPlugin.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPlugin.java index 5a015d8f98b..1670b64bab3 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPlugin.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPlugin.java @@ -25,7 +25,7 @@ import org.springframework.boot.gradle.task.Repackage; import org.springframework.boot.gradle.task.RunJar; /** - * Gradle 'Spring Boot' {@link Plugin}. + * Gradle 'Spring Boot' {@link Plugin}. Provides 2 tasks (bootRepackge and bootRun). * * @author Phillip Webb */ @@ -33,7 +33,7 @@ public class SpringBootPlugin implements Plugin { private static final String REPACKAGE_TASK_NAME = "bootRepackage"; - private static final String RUN_JAR_TASK_NAME = "runJar"; + private static final String RUN_JAR_TASK_NAME = "bootRun"; @Override public void apply(Project project) {