Commit 68b2ee3a authored by Andy Wilkinson's avatar Andy Wilkinson

Wrap spring-boot-cli.adoc at 90 characters

Closes gh-10834
parent f0901343
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
[partintro] [partintro]
-- --
The Spring Boot CLI is a command line tool that you can use if you want to quickly The Spring Boot CLI is a command line tool that you can use if you want to quickly develop
develop a Spring application. It lets you run Groovy scripts, which means that you have a a Spring application. It lets you run Groovy scripts, which means that you have a familiar
familiar Java-like syntax without so much boilerplate code. You can also bootstrap Java-like syntax without so much boilerplate code. You can also bootstrap a new project or
a new project or write your own command for it. write your own command for it.
-- --
...@@ -15,8 +15,8 @@ a new project or write your own command for it. ...@@ -15,8 +15,8 @@ a new project or write your own command for it.
== Installing the CLI == Installing the CLI
The Spring Boot CLI (Command-Line Interface) can be installed manually by using SDKMAN! The Spring Boot CLI (Command-Line Interface) can be installed manually by using SDKMAN!
(the SDK Manager) or by using Homebrew or MacPorts if you are an OSX user. See (the SDK Manager) or by using Homebrew or MacPorts if you are an OSX user. See
_<<getting-started.adoc#getting-started-installing-the-cli>>_ _<<getting-started.adoc#getting-started-installing-the-cli>>_ in the "`Getting started`"
in the "`Getting started`" section for comprehensive installation instructions. section for comprehensive installation instructions.
...@@ -104,8 +104,8 @@ To compile and run the application type the following command: ...@@ -104,8 +104,8 @@ To compile and run the application type the following command:
$ spring run hello.groovy $ spring run hello.groovy
---- ----
To pass command-line arguments to the application, use a `--` to separate To pass command-line arguments to the application, use a `--` to separate the commands
the commands from the "`spring`" command arguments, as shown in the following example: from the "`spring`" command arguments, as shown in the following example:
[indent=0,subs="verbatim,quotes,attributes"] [indent=0,subs="verbatim,quotes,attributes"]
---- ----
...@@ -126,14 +126,13 @@ are properly passed to the process. ...@@ -126,14 +126,13 @@ are properly passed to the process.
[[cli-deduced-grab-annotations]] [[cli-deduced-grab-annotations]]
==== Deduced "`grab`" Dependencies ==== Deduced "`grab`" Dependencies
Standard Groovy includes a `@Grab` annotation, which lets you declare dependencies Standard Groovy includes a `@Grab` annotation, which lets you declare dependencies on
on third-party libraries. This useful technique lets Groovy download jars in the third-party libraries. This useful technique lets Groovy download jars in the same way as
same way as Maven or Gradle would but without requiring you to use a build tool. Maven or Gradle would but without requiring you to use a build tool.
Spring Boot extends this technique further and tries to deduce which libraries to Spring Boot extends this technique further and tries to deduce which libraries to "`grab`"
"`grab`" based on your code. For example, since the `WebApplication` code shown based on your code. For example, since the `WebApplication` code shown previously uses
previously uses `@RestController` annotations, Spring Boot grabs"`Tomcat`" and `@RestController` annotations, Spring Boot grabs"`Tomcat`" and "`Spring MVC`".
"`Spring MVC`".
The following items are used as "`grab hints`": The following items are used as "`grab hints`":
...@@ -189,24 +188,24 @@ in the Spring Boot CLI source code to understand exactly how customizations are ...@@ -189,24 +188,24 @@ in the Spring Boot CLI source code to understand exactly how customizations are
[[cli-default-grab-deduced-coordinates]] [[cli-default-grab-deduced-coordinates]]
==== Deduced "`grab`" Coordinates ==== Deduced "`grab`" Coordinates
Spring Boot extends Groovy's standard `@Grab` support by letting you specify a dependency Spring Boot extends Groovy's standard `@Grab` support by letting you specify a dependency
without a group or version (for example, `@Grab('freemarker')`). Doing so consults Spring Boot's without a group or version (for example, `@Grab('freemarker')`). Doing so consults Spring
default dependency metadata to deduce the artifact's group and version. Note that the default Boot's default dependency metadata to deduce the artifact's group and version. Note that
metadata is tied to the version of the CLI that you use – it changes only when you move the default metadata is tied to the version of the CLI that you use – it changes only when
to a new version of the CLI, putting you in control of when the versions of your dependencies you move to a new version of the CLI, putting you in control of when the versions of your
may change. A table showing the dependencies and their versions that are included in the default dependencies may change. A table showing the dependencies and their versions that are
metadata can be found in the <<appendix-dependency-versions, appendix>>. included in the default metadata can be found in the <<appendix-dependency-versions,
appendix>>.
[[cli-default-import-statements]] [[cli-default-import-statements]]
==== Default Import Statements ==== Default Import Statements
To help reduce the size of your Groovy code, several `import` statements are To help reduce the size of your Groovy code, several `import` statements are automatically
automatically included. Notice how the preceding example refers to `@Component`, included. Notice how the preceding example refers to `@Component`, `@RestController`, and
`@RestController`, and `@RequestMapping` without needing to use `@RequestMapping` without needing to use fully-qualified names or `import` statements.
fully-qualified names or `import` statements.
TIP: Many Spring annotations work without using `import` statements. Try running TIP: Many Spring annotations work without using `import` statements. Try running your
your application to see what fails before adding imports. application to see what fails before adding imports.
...@@ -223,9 +222,9 @@ Unlike the equivalent Java application, you do not need to include a ...@@ -223,9 +222,9 @@ Unlike the equivalent Java application, you do not need to include a
==== Custom Dependency Management ==== Custom Dependency Management
By default, the CLI uses the dependency management declared in `spring-boot-dependencies` By default, the CLI uses the dependency management declared in `spring-boot-dependencies`
when resolving `@Grab` dependencies. Additional dependency management, which overrides when resolving `@Grab` dependencies. Additional dependency management, which overrides
the default dependency management, can be configured by using the `@DependencyManagementBom` the default dependency management, can be configured by using the
annotation. The annotation's value should specify the coordinates `@DependencyManagementBom` annotation. The annotation's value should specify the
(`groupId:artifactId:version`) of one or more Maven BOMs. coordinates (`groupId:artifactId:version`) of one or more Maven BOMs.
For example, consider the following declaration: For example, consider the following declaration:
...@@ -251,10 +250,10 @@ dependency management in `custom-bom`. ...@@ -251,10 +250,10 @@ dependency management in `custom-bom`.
You can use `@DependencyManagementBom` anywhere that you can use `@Grab`. However, to You can use `@DependencyManagementBom` anywhere that you can use `@Grab`. However, to
ensure consistent ordering of the dependency management, you can use ensure consistent ordering of the dependency management, you can use
`@DependencyManagementBom` at most once in your application. A useful source of `@DependencyManagementBom` at most once in your application. A useful source of dependency
dependency management (which is a superset of Spring Boot's dependency management) is the management (which is a superset of Spring Boot's dependency management) is the
http://platform.spring.io/[Spring IO Platform], which you might include with the http://platform.spring.io/[Spring IO Platform], which you might include with the following
following line: line:
[source,java,indent=0] [source,java,indent=0]
---- ----
...@@ -276,20 +275,20 @@ you use multiple files from a single directory, as shown in the following exampl ...@@ -276,20 +275,20 @@ you use multiple files from a single directory, as shown in the following exampl
[[cli-jar]] [[cli-jar]]
=== Packaging Your Application === Packaging Your Application
You can use the `jar` command to package your application into a self-contained You can use the `jar` command to package your application into a self-contained executable
executable jar file, as shown in the following example: jar file, as shown in the following example:
[indent=0] [indent=0]
---- ----
$ spring jar my-app.jar *.groovy $ spring jar my-app.jar *.groovy
---- ----
The resulting jar contains the classes produced by compiling the application and all The resulting jar contains the classes produced by compiling the application and all of
of the application's dependencies so that it can then be run by using `java -jar`. The jar the application's dependencies so that it can then be run by using `java -jar`. The jar
file also contains entries from the application's classpath. You can add explicit file also contains entries from the application's classpath. You can add explicit paths to
paths to the jar by using `--include` and `--exclude`. Both are comma-separated, and both the jar by using `--include` and `--exclude`. Both are comma-separated, and both accept
accept prefixes, in the form of "`+`" and "`-`", to signify that they should be removed from prefixes, in the form of "`+`" and "`-`", to signify that they should be removed from the
the defaults. The default includes are as follows: defaults. The default includes are as follows:
[indent=0] [indent=0]
---- ----
...@@ -309,8 +308,8 @@ Type `spring help jar` on the command line for more information. ...@@ -309,8 +308,8 @@ Type `spring help jar` on the command line for more information.
[[cli-init]] [[cli-init]]
=== Initialize a New Project === Initialize a New Project
The `init` command lets you create a new project by using https://start.spring.io The `init` command lets you create a new project by using https://start.spring.io without
without leaving the shell, as shown in the following example: leaving the shell, as shown in the following example:
[indent=0] [indent=0]
---- ----
...@@ -349,7 +348,8 @@ capabilities of the service by using the `--list` flag, as shown in the followin ...@@ -349,7 +348,8 @@ capabilities of the service by using the `--list` flag, as shown in the followin
---- ----
The `init` command supports many options. See the `help` output for more details. For The `init` command supports many options. See the `help` output for more details. For
instance, the following command creates a Gradle project that uses Java 8 and `war` packaging: instance, the following command creates a Gradle project that uses Java 8 and `war`
packaging:
[indent=0] [indent=0]
---- ----
...@@ -381,8 +381,8 @@ From inside the embedded shell, you can run other commands directly: ...@@ -381,8 +381,8 @@ From inside the embedded shell, you can run other commands directly:
Spring CLI v{spring-boot-version} Spring CLI v{spring-boot-version}
---- ----
The embedded shell supports ANSI color output as well as `tab` completion. If you need The embedded shell supports ANSI color output as well as `tab` completion. If you need to
to run a native command, you can use the `!` prefix. To exit the embedded shell, press run a native command, you can use the `!` prefix. To exit the embedded shell, press
`ctrl-c`. `ctrl-c`.
...@@ -426,9 +426,9 @@ following example: ...@@ -426,9 +426,9 @@ following example:
[[cli-groovy-beans-dsl]] [[cli-groovy-beans-dsl]]
== Developing Applications with the Groovy Beans DSL == Developing Applications with the Groovy Beans DSL
Spring Framework 4.0 has native support for a `beans{}` "`DSL`" (borrowed from Spring Framework 4.0 has native support for a `beans{}` "`DSL`" (borrowed from
http://grails.org/[Grails]), and you can embed bean definitions in your Groovy http://grails.org/[Grails]), and you can embed bean definitions in your Groovy application
application scripts by using the same format. This is sometimes a good way to include scripts by using the same format. This is sometimes a good way to include external
external features like middleware declarations, as shown in the following example: features like middleware declarations, as shown in the following example:
[source,groovy,indent=0] [source,groovy,indent=0]
---- ----
...@@ -474,20 +474,18 @@ to configure Aether. The following configuration settings are honored by the CLI ...@@ -474,20 +474,18 @@ to configure Aether. The following configuration settings are honored by the CLI
** Repositories ** Repositories
* Active profiles * Active profiles
See https://maven.apache.org/settings.html[Maven's settings documentation] for See https://maven.apache.org/settings.html[Maven's settings documentation] for further
further information. information.
[[cli-whats-next]] [[cli-whats-next]]
== What to Read Next == What to Read Next
There are some {github-code}/spring-boot-project/spring-boot-cli/samples[sample groovy There are some {github-code}/spring-boot-project/spring-boot-cli/samples[sample groovy
scripts] available from the GitHub repository that you can use to try out the scripts] available from the GitHub repository that you can use to try out the Spring Boot
Spring Boot CLI. There is also extensive Javadoc throughout the CLI. There is also extensive Javadoc throughout the {sc-spring-boot-cli}[source code].
{sc-spring-boot-cli}[source code].
If you find that you reach the limit of the CLI tool, you probably want to look at
If you find that you reach the limit of the CLI tool, you probably want to look converting your application to a full Gradle or Maven built "`Groovy project`". The
at converting your application to a full Gradle or Maven built "`Groovy project`". The next section covers Spring Boot's "<<build-tool-plugins.adoc#build-tool-plugins, Build
next section covers Spring Boot's tool plugins>>", which you can use with Gradle or Maven.
"<<build-tool-plugins.adoc#build-tool-plugins, Build tool plugins>>", which you can
use with Gradle or Maven.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment