Skip to content

Commit 450ab28

Browse files
committed
Merge branch '1.5.x'
2 parents fe63c98 + d0c3ece commit 450ab28

File tree

29 files changed

+1029
-70
lines changed

29 files changed

+1029
-70
lines changed

spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ The following configuration options are available:
484484
(defaults to a guess based on the archive type). See
485485
<<build-tool-plugins-gradle-configuration-layouts,available layouts for more details>>.
486486

487+
|'layoutFactory`
488+
|A layout factory that can be used if a custom layout is required. Alternative layouts
489+
can be provided by 3rd parties. Layout factories are only used when `layout` is not
490+
specified.
491+
487492
|`requiresUnpack`
488493
|A list of dependencies (in the form "`groupId:artifactId`" that must be unpacked from
489494
fat jars in order to run. Items are still packaged into the fat jar, but they will be
@@ -530,6 +535,38 @@ loader should be included or not. The following layouts are available:
530535

531536

532537

538+
+[[build-tool-plugins-gradle-configuration-custom-repackager]]
539+
+==== Using a custom layout
540+
If you have custom requirements for how to arrange the dependencies and loader classes
541+
inside the repackaged jar, you can use a custom layout. Any library which defines one
542+
or more `LayoutFactory` implementations can be added to the build script dependencies
543+
and then the layout factory becomes available in the `springBoot` configuration.
544+
For example:
545+
546+
[source,groovy,indent=0,subs="verbatim,attributes"]
547+
----
548+
buildscript {
549+
repositories {
550+
mavenCentral()
551+
}
552+
dependencies {
553+
classpath("org.springframework.boot:spring-boot-gradle-plugin:{spring-boot-version}")
554+
classpath("com.example:custom-layout:1.0.0")
555+
}
556+
}
557+
558+
springBoot {
559+
layoutFactory = new com.example.CustomLayoutFactory()
560+
}
561+
+----
562+
563+
NOTE: If there is only one custom `LayoutFactory` on the build classpath and it is
564+
listed in `META-INF/spring.factories` then it is unnecessary to explicitly set it in the
565+
`springBoot` configuration. Layout factories are only used when no explicit `layout` is
566+
specified.
567+
568+
569+
533570
[[build-tool-plugins-understanding-the-gradle-plugin]]
534571
=== Understanding how the Gradle plugin works
535572
When `spring-boot` is applied to your Gradle project a default task named `bootRepackage`

spring-boot-samples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<module>spring-boot-sample-atmosphere</module>
3333
<module>spring-boot-sample-batch</module>
3434
<module>spring-boot-sample-cache</module>
35+
<module>spring-boot-sample-custom-layout</module>
3536
<module>spring-boot-sample-data-cassandra</module>
3637
<module>spring-boot-sample-data-couchbase</module>
3738
<module>spring-boot-sample-data-elasticsearch</module>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<!-- Your own application should inherit from spring-boot-starter-parent -->
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-samples</artifactId>
9+
<version>1.5.0.BUILD-SNAPSHOT</version>
10+
</parent>
11+
<artifactId>spring-boot-sample-custom-layout</artifactId>
12+
<name>Spring Boot Custom Layout Sample</name>
13+
<description>Spring Boot Custom Layout Sample</description>
14+
<url>http://projects.spring.io/spring-boot/</url>
15+
<organization>
16+
<name>Pivotal Software, Inc.</name>
17+
<url>http://www.spring.io</url>
18+
</organization>
19+
<properties>
20+
<main.basedir>${basedir}/../..</main.basedir>
21+
</properties>
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-loader-tools</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-test</artifactId>
30+
<scope>test</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.gradle</groupId>
34+
<artifactId>gradle-tooling-api</artifactId>
35+
<version>${gradle.version}</version>
36+
<scope>test</scope>
37+
</dependency>
38+
</dependencies>
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-invoker-plugin</artifactId>
44+
<configuration>
45+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
46+
<settingsFile>src/it/settings.xml</settingsFile>
47+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
48+
<postBuildHookScript>verify</postBuildHookScript>
49+
<addTestClassPath>true</addTestClassPath>
50+
<skipInvocation>${skipTests}</skipInvocation>
51+
<streamLogs>true</streamLogs>
52+
</configuration>
53+
<executions>
54+
<execution>
55+
<id>integration-test</id>
56+
<goals>
57+
<goal>install</goal>
58+
<goal>run</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-failsafe-plugin</artifactId>
66+
</plugin>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-dependency-plugin</artifactId>
70+
<executions>
71+
<execution>
72+
<id>copy-effective-pom</id>
73+
<phase>generate-test-resources</phase>
74+
<goals>
75+
<goal>copy</goal>
76+
</goals>
77+
<configuration>
78+
<artifactItems>
79+
<artifactItem>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-dependencies</artifactId>
82+
<version>${project.version}</version>
83+
<type>effective-pom</type>
84+
<overWrite>true</overWrite>
85+
<outputDirectory>${project.build.directory}</outputDirectory>
86+
<destFileName>dependencies-pom.xml</destFileName>
87+
</artifactItem>
88+
</artifactItems>
89+
</configuration>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
</plugins>
94+
</build>
95+
<repositories>
96+
<repository>
97+
<id>gradle</id>
98+
<url>http://repo.gradle.org/gradle/libs-releases-local</url>
99+
<releases>
100+
<enabled>true</enabled>
101+
</releases>
102+
<snapshots>
103+
<enabled>false</enabled>
104+
</snapshots>
105+
</repository>
106+
</repositories>
107+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
buildscript {
2+
repositories {
3+
flatDir {
4+
dirs '../..'
5+
}
6+
mavenLocal()
7+
}
8+
dependencies {
9+
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
10+
classpath "org.springframework.boot:spring-boot-sample-custom-layout:${project.bootVersion}"
11+
}
12+
}
13+
14+
repositories {
15+
mavenLocal()
16+
mavenCentral()
17+
}
18+
19+
apply plugin: 'java'
20+
apply plugin: 'org.springframework.boot'
21+
22+
springBoot {
23+
layoutFactory = new sample.layout.SampleLayoutFactory('custom')
24+
}
25+
26+
dependencies {
27+
compile 'org.springframework.boot:spring-boot-starter'
28+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.springframework.boot.maven.it</groupId>
6+
<artifactId>custom</artifactId>
7+
<version>0.0.1.BUILD-SNAPSHOT</version>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
</properties>
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<groupId>org.springframework.boot</groupId>
15+
<artifactId>spring-boot-maven-plugin</artifactId>
16+
<version>@project.version@</version>
17+
<executions>
18+
<execution>
19+
<goals>
20+
<goal>repackage</goal>
21+
</goals>
22+
<configuration>
23+
<layoutFactory implementation="sample.layout.SampleLayoutFactory">
24+
<name>custom</name>
25+
</layoutFactory>
26+
</configuration>
27+
</execution>
28+
</executions>
29+
<dependencies>
30+
<dependency>
31+
<groupId>@project.groupId@</groupId>
32+
<artifactId>@project.artifactId@</artifactId>
33+
<version>@project.version@</version>
34+
</dependency>
35+
</dependencies>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
<dependencies>
40+
</dependencies>
41+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2012-2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.test;
18+
19+
public class SampleApplication {
20+
21+
public static void main(String[] args) {
22+
}
23+
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java.io.*;
2+
import sample.layout.*;
3+
4+
Verify.verify(
5+
new File( basedir, "target/custom-0.0.1.BUILD-SNAPSHOT.jar" ), "custom"
6+
);
7+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
buildscript {
2+
repositories {
3+
flatDir {
4+
dirs '../..'
5+
}
6+
mavenLocal()
7+
}
8+
dependencies {
9+
classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}"
10+
classpath "org.springframework.boot:spring-boot-sample-custom-layout:${project.bootVersion}"
11+
}
12+
}
13+
14+
repositories {
15+
mavenLocal()
16+
mavenCentral()
17+
}
18+
19+
apply plugin: 'java'
20+
apply plugin: 'org.springframework.boot'
21+
22+
dependencies {
23+
compile 'org.springframework.boot:spring-boot-starter'
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>org.springframework.boot.maven.it</groupId>
6+
<artifactId>default</artifactId>
7+
<version>0.0.1.BUILD-SNAPSHOT</version>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
</properties>
11+
<build>
12+
<plugins>
13+
<plugin>
14+
<groupId>org.springframework.boot</groupId>
15+
<artifactId>spring-boot-maven-plugin</artifactId>
16+
<version>@project.version@</version>
17+
<executions>
18+
<execution>
19+
<goals>
20+
<goal>repackage</goal>
21+
</goals>
22+
</execution>
23+
</executions>
24+
<dependencies>
25+
<dependency>
26+
<groupId>@project.groupId@</groupId>
27+
<artifactId>@project.artifactId@</artifactId>
28+
<version>@project.version@</version>
29+
</dependency>
30+
</dependencies>
31+
</plugin>
32+
</plugins>
33+
</build>
34+
<dependencies>
35+
</dependencies>
36+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2012-2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.test;
18+
19+
public class SampleApplication {
20+
21+
public static void main(String[] args) {
22+
}
23+
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java.io.*;
2+
import sample.layout.*;
3+
4+
Verify.verify(
5+
new File( basedir, "target/default-0.0.1.BUILD-SNAPSHOT.jar" ), "sample"
6+
);
7+

0 commit comments

Comments
 (0)