Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c713c809
Commit
c713c809
authored
Jun 24, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
ed3df32c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
82 deletions
+79
-82
JacksonAutoConfiguration.java
.../boot/autoconfigure/jackson/JacksonAutoConfiguration.java
+21
-20
build-tool-plugins.adoc
spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc
+4
-5
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+35
-37
FlatdirTests.java
...st/java/org/springframework/boot/gradle/FlatdirTests.java
+13
-13
ApplyExcludeRules.java
...pringframework/boot/gradle/exclude/ApplyExcludeRules.java
+6
-7
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java
View file @
c713c809
...
...
@@ -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
)
...
...
spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc
View file @
c713c809
...
...
@@ -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
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
c713c809
...
...
@@ -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
...
...
spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/FlatdirTests.java
View file @
c713c809
...
...
@@ -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
();
}
}
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/exclude/ApplyExcludeRules.java
View file @
c713c809
...
...
@@ -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"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment