Commit c713c809 authored by Phillip Webb's avatar Phillip Webb

Polish

parent ed3df32c
......@@ -73,26 +73,27 @@ public class JacksonAutoConfiguration {
.values();
}
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
static class JacksonObjectMapperAutoConfiguration {
@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();
@Bean
@Primary
@ConditionalOnMissingBean
public ObjectMapper jacksonObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
if (this.properties.isJsonSortKeys()) {
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
}
return objectMapper;
}
}
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
static class JacksonObjectMapperAutoConfiguration {
@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();
@Bean
@Primary
@ConditionalOnMissingBean
public ObjectMapper jacksonObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
if (this.properties.isJsonSortKeys()) {
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
true);
}
return objectMapper;
}
}
@Configuration
@ConditionalOnClass(JodaModule.class)
......
......@@ -405,7 +405,7 @@ The following configuration options are available:
|Name |Description
|`enabled`
|Boolean flag to switch the repackager off (sometimes useful if you
|Boolean flag to switch the repackager off (sometimes useful if you
want the other Boot features but not this one)
|`mainClass`
......@@ -423,10 +423,9 @@ want the other Boot features but not this one)
the original jar as a dependency in another project, it's best to use an extension to
define the executable archive.
|`withJarTask`
|The name or value of the `Jar` task (defaults to all
tasks of type `Jar`) which is used to locate the archive to
repackage.
|`withJarTask`
|The name or value of the `Jar` task (defaults to all tasks of type `Jar`) which is used
to locate the archive to repackage.
|`customConfiguration`
|The name of the custom configuration whuch is used to populate the nested lib directory
......
......@@ -1581,15 +1581,13 @@ details.
[[howto-create-an-additional-executable-jar]]
=== Create an additional executable JAR
If you want to use your project as a library jar for other projects to depend on, and in
addition have an executable (e.g. demo) version of it, you will want to configure the
build in a slightly different way.
If you want to use your project as a library jar for other projects to
depend on, and in addition have an executable (e.g. demo) version of
it, you will want to configure the build in a slightly different way.
For Maven the normal JAR plugin and the Spring Boot plugin both have a
"classifier" configuration that you can add to create an additional JAR.
Example (using the Spring Boot Starter Parent to manage the plugin
versions and other configuration defaults):
For Maven the normal JAR plugin and the Spring Boot plugin both have a ``classifier''
configuration that you can add to create an additional JAR. Example (using the Spring
Boot Starter Parent to manage the plugin versions and other configuration defaults):
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
......@@ -1606,28 +1604,27 @@ versions and other configuration defaults):
</build>
----
Two jars are produced, the default one, and an executable one using
the Boot plugin with classifier "exec".
Two jars are produced, the default one, and an executable one using the Boot plugin with
classifier ``exec''.
For Gradle users the steps are similar. Example:
[source,groovy,indent=0,subs="verbatim,attributes"]
----
bootRepackage {
classifier = 'exec'
}
bootRepackage {
classifier = 'exec'
}
----
[[howto-create-a-nonexecutable-jar]]
=== Create a non-executable JAR with exclusions
Often if you have an executable and a non-executable jar as build products, the executable
version will have additional configuration files that are not needed in a library jar.
E.g. the `application.yml` configuration file might excluded from the non-executable JAR.
Often if you have an executable and a non-executable jar
as build products, the executable version will have additional
configuration files that are not needed in a library jar. E.g. the
`application.yml` configuration file might excluded from the
non-executable JAR.
Here's how to do that in Maven
Here's how to do that in Maven:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
......@@ -1672,30 +1669,31 @@ Here's how to do that in Maven
</build>
----
In Gradle you can create a new JAR archive with standard task DSL
features, and then have the `bootRepackage` task depend on that one
using its `withJarTask` property:
In Gradle you can create a new JAR archive with standard task DSL features, and then have
the `bootRepackage` task depend on that one using its `withJarTask` property:
[source,groovy,indent=0,subs="verbatim,attributes"]
----
jar {
baseName = 'spring-boot-sample-profile'
version = '0.0.0'
excludes = ['**/application.yml']
}
jar {
baseName = 'spring-boot-sample-profile'
version = '0.0.0'
excludes = ['**/application.yml']
}
task('execJar', type:Jar, dependsOn: 'jar') {
baseName = 'spring-boot-sample-profile'
version = '0.0.0'
classifier = 'exec'
from sourceSets.main.output
}
task('execJar', type:Jar, dependsOn: 'jar') {
baseName = 'spring-boot-sample-profile'
version = '0.0.0'
classifier = 'exec'
from sourceSets.main.output
}
bootRepackage {
withJarTask = tasks['execJar']
}
bootRepackage {
withJarTask = tasks['execJar']
}
----
[[howto-remote-debug-maven-run]]
=== Remote debug a Spring Boot application started with Maven
To attach a remote debugger to a Spring Boot application started with Maven you can use
......
......@@ -27,7 +27,7 @@ import org.springframework.util.FileSystemUtils;
/**
* Tests for using the Gradle plugin's support for flat directory repos
*
*
* @author Dave Syer
*/
public class FlatdirTests {
......@@ -36,26 +36,26 @@ public class FlatdirTests {
private File libs = new File("target/flatdir/lib");
private static final String BOOT_VERSION = ManagedDependencies.get().find(
"spring-boot").getVersion();
private static final String BOOT_VERSION = ManagedDependencies.get()
.find("spring-boot").getVersion();
@Before
public void init() {
if (libs.exists()) {
FileSystemUtils.deleteRecursively(libs);
if (this.libs.exists()) {
FileSystemUtils.deleteRecursively(this.libs);
}
}
@Test
public void flatdir() throws Exception {
project = new ProjectCreator().createProject("flatdir");
if (!libs.exists()) {
libs.mkdirs();
this.project = new ProjectCreator().createProject("flatdir");
if (!this.libs.exists()) {
this.libs.mkdirs();
}
FileCopyUtils.copy(new File("src/test/resources/foo.jar"),
new File(libs, "foo-1.0.0.jar"));
project.newBuild().forTasks("build").withArguments(
"-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
FileCopyUtils.copy(new File("src/test/resources/foo.jar"), new File(this.libs,
"foo-1.0.0.jar"));
this.project.newBuild().forTasks("build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
}
}
......@@ -49,12 +49,10 @@ public class ApplyExcludeRules implements Action<Configuration> {
if (!VersionManagedDependencies.CONFIGURATION.equals(configuration.getName())) {
configuration.getIncoming().beforeResolve(
new Action<ResolvableDependencies>() {
@Override
public void execute(ResolvableDependencies resolvableDependencies) {
resolvableDependencies.getDependencies().all(
new Action<Dependency>() {
@Override
public void execute(Dependency dependency) {
applyExcludeRules(dependency);
......@@ -72,11 +70,12 @@ public class ApplyExcludeRules implements Action<Configuration> {
}
private void applyExcludeRules(ModuleDependency dependency) {
ManagedDependencies managedDependencies = versionManagedDependencies.getManagedDependencies();
ManagedDependencies managedDependencies = versionManagedDependencies
.getManagedDependencies();
// flat directory repositories do not have groups
if (dependency.getGroup() != null) {
org.springframework.boot.dependency.tools.Dependency managedDependency = managedDependencies.find(
dependency.getGroup(), dependency.getName());
org.springframework.boot.dependency.tools.Dependency managedDependency = managedDependencies
.find(dependency.getGroup(), dependency.getName());
if (managedDependency != null) {
for (Exclusion exclusion : managedDependency.getExclusions()) {
addExcludeRule(dependency, exclusion);
......@@ -109,8 +108,8 @@ public class ApplyExcludeRules implements Action<Configuration> {
private boolean isStarter(ModuleDependency dependency) {
return (dependency.getGroup() != null
&& dependency.getGroup().equals("org.springframework.boot") && dependency.getName().startsWith(
"spring-boot-starter"));
&& dependency.getGroup().equals("org.springframework.boot") && dependency
.getName().startsWith("spring-boot-starter"));
}
}
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