mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Add maven plugin documentation
This commit adds the generated site for the maven plugin alongside the developer guide and javadoc. The maven plugin is available in the "/maven-plugin" context. The advanced information described in the developer guide have been migrated to the plugin site as most the information is taken from the code itself, which avoids duplication. Fixes #749
This commit is contained in:
parent
a3b422ffc8
commit
888703cf26
@ -223,6 +223,31 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack-maven-plugin</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>site</classifier>
|
||||
<type>zip</type>
|
||||
<outputDirectory>${project.build.directory}/contents</outputDirectory>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
|
@ -15,7 +15,7 @@ unsupported build system. If you are just getting started, you might want to rea
|
||||
|
||||
[[build-tool-plugins-maven-plugin]]
|
||||
== Spring Boot Maven plugin
|
||||
The Spring Boot Maven Plugin provides Spring Boot support in Maven, allowing you to
|
||||
The {mp-root}/[Spring Boot Maven Plugin] provides Spring Boot support in Maven, allowing you to
|
||||
package executable jar or war archives and run an application ``in-place''. To use it you
|
||||
must be using Maven 3 (or better).
|
||||
|
||||
@ -151,145 +151,7 @@ need to mark the embedded container dependencies as ``provided'', e.g:
|
||||
</project>
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-maven-packaging-configuration]]
|
||||
=== Repackage configuration
|
||||
The following configuration options are available for the `spring-boot:repackage` goal:
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-maven-packaging-required-params]]
|
||||
==== Required parameters
|
||||
[cols="2,4"]
|
||||
|===
|
||||
|Name |Description
|
||||
|
||||
|`outputDirectory`
|
||||
|Directory containing the generated archive (defaults to `${project.build.directory}`).
|
||||
|
||||
|`finalName`
|
||||
|Name of the generated archive (defaults to `${project.build.finalName}`).
|
||||
|===
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-maven-packaging-optional-params]]
|
||||
==== Optional parameters
|
||||
[cols="2,4"]
|
||||
|===
|
||||
|Name |Description
|
||||
|
||||
|`classifier`
|
||||
|Classifier to add to the generated artifact. If given, the artifact will be attached. If
|
||||
this is not given, it will merely be written to the output directory according to the
|
||||
`finalName`. Attaching the artifact allows to deploy it alongside to the original one,
|
||||
see http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html[
|
||||
the maven documentation for more details]
|
||||
|
||||
|`mainClass`
|
||||
|The name of the main class. If not specified will search for a single compiled class
|
||||
that contains a `main` method.
|
||||
|
||||
|`layout`
|
||||
|The type of archive (which corresponds to how the dependencies are laid out inside it).
|
||||
Defaults to a guess based on the archive type.
|
||||
|===
|
||||
|
||||
The plugin rewrites your manifest, and in particular it manages the `Main-Class` and
|
||||
`Start-Class` entries, so if the defaults don't work you have to configure those there
|
||||
(not in the jar plugin). The `Main-Class` in the manifest is actually controlled by the
|
||||
`layout` property of the boot plugin, e.g.
|
||||
|
||||
[source,xml,indent=0,subs="verbatim,attributes"]
|
||||
----
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>{spring-boot-version}</version>
|
||||
<configuration>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<layout>ZIP</layout>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
----
|
||||
|
||||
The layout property defaults to a guess based on the archive type (jar or war). For the
|
||||
`PropertiesLauncher` the layout is ``ZIP'' (even though the output might be a jar file).
|
||||
|
||||
TIP: The executable jar format is <<appendix-executable-jar-format.adoc#executable-jar,
|
||||
described in the appendix>>.
|
||||
|
||||
[[build-tool-plugins-maven-running-applications]]
|
||||
=== Running applications
|
||||
The Spring Boot Maven Plugin includes a `run` goal which can be used to launch your
|
||||
application from the command line. Type the following from the root of your Maven
|
||||
project:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ mvn spring-boot:run
|
||||
----
|
||||
|
||||
By default, any `src/main/resources` folder will be added to the application classpath
|
||||
when you run via the maven plugin. This allows hot refreshing of resources which can be
|
||||
very useful when developing web applications. For example, you can work on HTML, CSS or
|
||||
JavaScipt files and see your changes immediately without recompiling your application. It
|
||||
is also a helpful way of allowing your front end developers to work without needing to
|
||||
download and install a Java IDE.
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-maven-run-configuration]]
|
||||
=== Run configuration
|
||||
The following configuration options are available for the `spring-boot:run` goal:
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-maven-run-configuration-required-params]]
|
||||
=== Required parameters
|
||||
[cols="2,4"]
|
||||
|===
|
||||
|Name |Description
|
||||
|
||||
|`classesDirectrory`
|
||||
|Directory containing the classes and resource files that should be packaged into the
|
||||
archive (defaults to `${project.build.outputDirectory}`).
|
||||
|===
|
||||
|
||||
|
||||
|
||||
[[build-tool-plugins-maven-run-configuration-optional-params]]
|
||||
=== Optional parameters
|
||||
[cols="2,4"]
|
||||
|===
|
||||
|Name |Description
|
||||
|
||||
|`arguments` or `-Drun.arguments`
|
||||
|Arguments that should be passed to the application (comma-separated).
|
||||
|
||||
|`addResources` or `-Drun.addResources`
|
||||
|Add Maven resources to the classpath directly, this allows live in-place editing or
|
||||
resources. Since resources will be added directly, and via the target/classes folder
|
||||
they will appear twice if `ClassLoader.getResources()` is called. In practice, however,
|
||||
most applications call `ClassLoader.getResource()` which will always return the first
|
||||
resource (defaults to `true`).
|
||||
|
||||
|`mainClass`
|
||||
|The name of the main class. If not specified the first compiled class found that
|
||||
contains a 'main' method will be used.
|
||||
|
||||
|`folders`
|
||||
|Folders that should be added to the classpath (defaults to
|
||||
`${project.build.outputDirectory}`).
|
||||
|===
|
||||
Advanced configuration options and examples are available in the {mp-root}/[plugin info page].
|
||||
|
||||
|
||||
|
||||
|
@ -25,6 +25,7 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
|
||||
:dc-spring-boot: {dc-root}/org/springframework/boot
|
||||
:dc-spring-boot-autoconfigure: {dc-root}/org/springframework/boot/autoconfigure
|
||||
:dc-spring-boot-actuator: {dc-root}/org/springframework/boot/actuate
|
||||
:mp-root: http://docs.spring.io/spring-boot/docs/{spring-boot-docs-version}/maven-plugin
|
||||
:spring-reference: http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle
|
||||
:spring-security-reference: http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle
|
||||
:spring-javadoc: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework
|
||||
|
@ -31,6 +31,14 @@
|
||||
<connection>scm:git:git://github.com/spring-projects/spring-boot.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-projects/spring-boot.git</developerConnection>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
<system>Github</system>
|
||||
<url>https://github.com/spring-projects/spring-boot/issues</url>
|
||||
</issueManagement>
|
||||
<ciManagement>
|
||||
<system>Bamboo</system>
|
||||
<url>https://build.spring.io/browse/BOOT-PUB</url>
|
||||
</ciManagement>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Additional Dependencies the consumers of spring-boot-dependencies
|
||||
@ -241,6 +249,7 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<version>3.2</version>
|
||||
</plugin>
|
||||
@ -249,6 +258,11 @@
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sonar-maven-plugin</artifactId>
|
||||
|
@ -50,6 +50,31 @@
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>full</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/assemble/site.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-site-zip</id>
|
||||
<phase>site</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<dependencies>
|
||||
<!-- Compile -->
|
||||
@ -120,27 +145,52 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
<configuration>
|
||||
<goalPrefix>spring-boot</goalPrefix>
|
||||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-descriptor</id>
|
||||
<id>generate-descriptor</id>
|
||||
<goals>
|
||||
<goal>descriptor</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>help-descriptor</id>
|
||||
<id>generated-helpmojo</id>
|
||||
<goals>
|
||||
<goal>helpmojo</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-plugin-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.7</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>index</report>
|
||||
<report>cim</report>
|
||||
<report>issue-tracking</report>
|
||||
<report>license</report>
|
||||
<report>scm</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</reporting>
|
||||
</project>
|
||||
|
@ -0,0 +1,15 @@
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
<id>site</id>
|
||||
<baseDirectory>maven-plugin</baseDirectory>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}/site</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
@ -37,39 +37,46 @@ import org.springframework.boot.loader.tools.Libraries;
|
||||
import org.springframework.boot.loader.tools.Repackager;
|
||||
|
||||
/**
|
||||
* MOJO that can can be used to repackage existing JAR and WAR archives so that they can
|
||||
* be executed from the command line using {@literal java -jar}. With
|
||||
* <code>layout=NONE</code> can also be used simply to package a JAR with nested
|
||||
* dependencies (and no main class, so not executable).
|
||||
* Repackages existing JAR and WAR archives so that they can be executed from
|
||||
* the command line using {@literal java -jar}. With <code>layout=NONE</code>
|
||||
* can also be used simply to package a JAR with nested dependencies (and
|
||||
* no main class, so not executable).
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Mojo(name = "repackage", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
|
||||
@Mojo(name = "repackage", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true,
|
||||
threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
|
||||
requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
|
||||
public class RepackageMojo extends AbstractMojo {
|
||||
|
||||
private static final long FIND_WARNING_TIMEOUT = TimeUnit.SECONDS.toMillis(10);
|
||||
|
||||
/**
|
||||
* The Maven project.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(defaultValue = "${project}", readonly = true, required = true)
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* Maven project helper utils.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Component
|
||||
private MavenProjectHelper projectHelper;
|
||||
|
||||
/**
|
||||
* Directory containing the generated archive.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(defaultValue = "${project.build.directory}", required = true)
|
||||
private File outputDirectory;
|
||||
|
||||
/**
|
||||
* Name of the generated archive.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(defaultValue = "${project.build.finalName}", required = true)
|
||||
private String finalName;
|
||||
@ -77,7 +84,10 @@ public class RepackageMojo extends AbstractMojo {
|
||||
/**
|
||||
* Classifier to add to the artifact generated. If given, the artifact will be
|
||||
* attached. If this is not given, it will merely be written to the output directory
|
||||
* according to the finalName.
|
||||
* according to the finalName. Attaching the artifact allows to deploy it alongside
|
||||
* to the original one, see <a href="http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html">
|
||||
* the maven documentation for more details</a>.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter
|
||||
private String classifier;
|
||||
@ -85,12 +95,16 @@ public class RepackageMojo extends AbstractMojo {
|
||||
/**
|
||||
* The name of the main class. If not specified the first compiled class found that
|
||||
* contains a 'main' method will be used.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter
|
||||
private String mainClass;
|
||||
|
||||
/**
|
||||
* The layout to use (JAR, WAR, ZIP, DIR, NONE) in case it cannot be inferred.
|
||||
* The type of archive (which corresponds to how the dependencies are laid out
|
||||
* inside it). Possible values are JAR, WAR, ZIP, DIR, NONE. Defaults to a
|
||||
* guess based on the archive type.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter
|
||||
private LayoutType layout;
|
||||
|
@ -43,11 +43,13 @@ import org.springframework.boot.loader.tools.RunProcess;
|
||||
import edu.emory.mathcs.backport.java.util.Arrays;
|
||||
|
||||
/**
|
||||
* MOJO that can be used to run a executable archive application directly from Maven.
|
||||
* Run an executable archive application.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Mojo(name = "run", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE, requiresDependencyResolution = ResolutionScope.TEST)
|
||||
@Mojo(name = "run", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE,
|
||||
requiresDependencyResolution = ResolutionScope.TEST)
|
||||
@Execute(phase = LifecyclePhase.TEST_COMPILE)
|
||||
public class RunMojo extends AbstractMojo {
|
||||
|
||||
@ -55,25 +57,32 @@ public class RunMojo extends AbstractMojo {
|
||||
|
||||
/**
|
||||
* The Maven project.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(defaultValue = "${project}", readonly = true, required = true)
|
||||
private MavenProject project;
|
||||
|
||||
/**
|
||||
* Add maven resources to the classpath directly, this allows live in-place editing or
|
||||
* resources.
|
||||
* resources. Since resources will be added directly, and via the target/classes folder
|
||||
* they will appear twice if {@code ClassLoader.getResources()} is called. In practice,
|
||||
* however, most applications call {@code ClassLoader.getResource()} which will always
|
||||
* return the first resource.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(property = "run.addResources", defaultValue = "true")
|
||||
private boolean addResources;
|
||||
|
||||
/**
|
||||
* Path to agent jar.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(property = "run.agent")
|
||||
private File[] agent;
|
||||
|
||||
/**
|
||||
* Flag to say that the agent requires -noverify.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(property = "run.noverify")
|
||||
private Boolean noverify;
|
||||
@ -81,6 +90,7 @@ public class RunMojo extends AbstractMojo {
|
||||
/**
|
||||
* Arguments that should be passed to the application. On command line use commas to
|
||||
* separate multiple arguments.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(property = "run.arguments")
|
||||
private String[] arguments;
|
||||
@ -88,12 +98,15 @@ public class RunMojo extends AbstractMojo {
|
||||
/**
|
||||
* The name of the main class. If not specified the first compiled class found that
|
||||
* contains a 'main' method will be used.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter
|
||||
private String mainClass;
|
||||
|
||||
/**
|
||||
* Folders that should be added to the classpath.
|
||||
* Additional folders besides the classes directory that should be added to
|
||||
* the classpath.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter
|
||||
private String[] folders;
|
||||
@ -101,6 +114,7 @@ public class RunMojo extends AbstractMojo {
|
||||
/**
|
||||
* Directory containing the classes and resource files that should be packaged into
|
||||
* the archive.
|
||||
* @since 1.0
|
||||
*/
|
||||
@Parameter(defaultValue = "${project.build.outputDirectory}", required = true)
|
||||
private File classesDirectory;
|
||||
|
@ -0,0 +1,49 @@
|
||||
-----
|
||||
Repackage classifier
|
||||
-----
|
||||
Stephane Nicoll
|
||||
-----
|
||||
2014-05-02
|
||||
-----
|
||||
|
||||
By default, the <<<repackage>>> goal will replace the original artifact with the
|
||||
executable one. If you prefer to keep the original artifact and attach the executable
|
||||
one with a different classifier, configure the plugin as follows:
|
||||
|
||||
---
|
||||
<project>
|
||||
...
|
||||
<build>
|
||||
...
|
||||
<plugins>
|
||||
...
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classifier>exec</classifier>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
...
|
||||
</plugin>
|
||||
...
|
||||
</plugins>
|
||||
...
|
||||
</build>
|
||||
...
|
||||
</project>
|
||||
---
|
||||
|
||||
This configuration will generate two artifacts: the original one and the executable counter
|
||||
part produced by the repackage goal. Both will be installed/deployed accordingly.
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,44 @@
|
||||
-----
|
||||
Spring Boot
|
||||
-----
|
||||
Stephane Nicoll
|
||||
-----
|
||||
2014-05-02
|
||||
-----
|
||||
|
||||
Spring Boot Maven Plugin
|
||||
|
||||
The Spring Boot Maven Plugin provides Spring Boot support in Maven, allowing you to package executable
|
||||
jar or war archives and run an application “in-place”.
|
||||
|
||||
* Goals Overview
|
||||
|
||||
The Spring Boot Plugin has the following goals.
|
||||
|
||||
* {{{./run-mojo.html}spring-boot:run}} runs your Spring Boot application.
|
||||
|
||||
* {{{./repackage-mojo.html}spring-boot:repackage}} repackages your jar/war to be executable.
|
||||
|
||||
* Usage
|
||||
|
||||
General instructions on how to use the Spring Boot Plugin can be found on the {{{./usage.html}usage page}}. Some
|
||||
more specific use cases are described in the examples given below.
|
||||
|
||||
In case you still have questions regarding the plugin's usage, please have a look at the existing
|
||||
{{{http://stackoverflow.com/questions/tagged/spring-boot}stack overflow issue}}. If you still don't get an
|
||||
answer, feel free to create a new thread with the <<<#spring-boot>>> tag.
|
||||
|
||||
If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report
|
||||
in our {{{./issue-tracking.html}issue tracker}}.
|
||||
|
||||
* Examples
|
||||
|
||||
To provide you with better understanding of some usages of Spring Boot, you can take a look into
|
||||
the following examples:
|
||||
|
||||
* {{{./examples/repackage-classifier.html}Custom repackage classifier}}
|
||||
|
||||
[]
|
||||
|
||||
|
||||
|
@ -0,0 +1,123 @@
|
||||
|
||||
-----
|
||||
Usage
|
||||
-----
|
||||
Stephane Nicoll
|
||||
-----
|
||||
2014-05-02
|
||||
-----
|
||||
|
||||
Usage
|
||||
|
||||
The plugin offers a goal for repackaging an application as an executable JAR/WAR as well as a goal
|
||||
for running the application.
|
||||
|
||||
* Repackaging an application
|
||||
|
||||
In order to repackage your application, you simply need to add a reference to the
|
||||
plugin in your <<<pom.xml>>>:
|
||||
|
||||
---
|
||||
<build>
|
||||
...
|
||||
<plugins>
|
||||
...
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
...
|
||||
</plugins>
|
||||
...
|
||||
</build>
|
||||
---
|
||||
|
||||
The example above repackages a jar or war that is built during the package phase of the Maven lifecycle. The
|
||||
original (i.e. non exectuable) artifact is renamed to <<<.original>>> by default but it is also possible to
|
||||
keep the original artifact using a custom classifier.
|
||||
|
||||
The plugin rewrites your manifest, and in particular it manages the <<Main-Class>> and <<Start-Class>>
|
||||
entries, so if the defaults don't work you have to configure those there (not in the jar plugin). The
|
||||
<<Main-Class>> in the manifest is actually controlled by the <<layout>> property of the boot plugin, e.g.
|
||||
|
||||
---
|
||||
<build>
|
||||
...
|
||||
<plugins>
|
||||
...
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<layout>ZIP</layout>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
...
|
||||
</plugins>
|
||||
...
|
||||
</build>
|
||||
---
|
||||
|
||||
The layout property defaults to a guess based on the archive type (jar or war). For the
|
||||
<<<PropertiesLauncher>>> the layout is <<<ZIP>>> (even though the output might be a jar file).
|
||||
|
||||
For more detailed examples of how to configure this goal see:
|
||||
|
||||
* {{{./examples/repackage-classifier.html}Custom repackage classifier}}
|
||||
|
||||
[]
|
||||
|
||||
* Running the application
|
||||
|
||||
The plugin includes a run goal which can be used to launch your application from the command
|
||||
line:
|
||||
|
||||
---
|
||||
mvn spring-boot:run
|
||||
---
|
||||
|
||||
By default, any <<src/main/resources>> folder will be added to the application classpath
|
||||
when you run the application. This allows hot refreshing of resources which can be very
|
||||
useful when developing web applications. For example, you can work on HTML, CSS or JavaScipt
|
||||
files and see your changes immediately without recompiling your application. It is also a
|
||||
helpful way of allowing your front end developers to work without needing to download and
|
||||
install a Java IDE.
|
||||
|
||||
Of course, if your resources are using tokens that are filtered by Maven, you may want
|
||||
to disable that feature as follows:
|
||||
|
||||
---
|
||||
<build>
|
||||
...
|
||||
<plugins>
|
||||
...
|
||||
<plugin>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<addResources>false</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
...
|
||||
</plugins>
|
||||
...
|
||||
</build>
|
||||
---
|
19
spring-boot-tools/spring-boot-maven-plugin/src/site/site.xml
Normal file
19
spring-boot-tools/spring-boot-maven-plugin/src/site/site.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
|
||||
<body>
|
||||
<menu name="Overview">
|
||||
<item name="Introduction" href="index.html"/>
|
||||
<item name="Goals" href="plugin-info.html"/>
|
||||
<item name="Usage" href="usage.html"/>
|
||||
</menu>
|
||||
<menu name="Examples">
|
||||
<item name="Custom repackage classifier" href="examples/repackage-classifier.html"/>
|
||||
</menu>
|
||||
<menu ref="reports"/>
|
||||
</body>
|
||||
<skin>
|
||||
<groupId>org.apache.maven.skins</groupId>
|
||||
<artifactId>maven-fluido-skin</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</skin>
|
||||
</project>
|
Loading…
Reference in New Issue
Block a user