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
fd47b728
Commit
fd47b728
authored
Apr 24, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly handle values with spaces
Closes gh-10741
parent
d4729f53
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
10 deletions
+15
-10
AbstractRunMojo.java
.../java/org/springframework/boot/maven/AbstractRunMojo.java
+3
-7
run-env-variables.apt.vm
...ven-plugin/src/site/apt/examples/run-env-variables.apt.vm
+2
-1
run-system-properties.apt.vm
...plugin/src/site/apt/examples/run-system-properties.apt.vm
+3
-1
SystemPropertyFormatterTests.java
...ingframework/boot/maven/SystemPropertyFormatterTests.java
+7
-1
No files found.
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java
View file @
fd47b728
...
...
@@ -569,18 +569,14 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
*/
static
class
SystemPropertyFormatter
{
private
static
final
String
NO_VALUE_FORMAT
=
"-D%s"
;
private
static
final
String
KEY_VALUE_FORMAT
=
NO_VALUE_FORMAT
+
"=%s"
;
public
static
String
format
(
Object
key
,
Object
value
)
{
if
(
key
==
null
)
{
return
""
;
}
if
(
value
==
null
||
String
.
valueOf
(
value
).
trim
().
isEmpty
())
{
return
String
.
format
(
NO_VALUE_FORMAT
,
key
);
if
(
value
==
null
||
String
.
valueOf
(
value
).
isEmpty
())
{
return
String
.
format
(
"-D%s"
,
key
);
}
return
String
.
format
(
KEY_VALUE_FORMAT
,
key
,
value
);
return
String
.
format
(
"-D%s=\"%s\""
,
key
,
value
);
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-env-variables.apt.vm
View file @
fd47b728
...
...
@@ -39,7 +39,8 @@ Dmytro Nosan
---
If the value is empty or not defined (i.e. <<<<MY_ENV/>>>>), the env variable is set
with an empty String as the value.
with an empty String as the value. Maven trims values specified in the pom so it is
not possible to specify a env variable who needs to start or end with a space.
Any String typed Maven variable can be passed as system properties. Any attempt to pass
any other Maven variable type (e.g. a <<<List>>> or a <<<URL>>> variable) will cause the
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/run-system-properties.apt.vm
View file @
fd47b728
...
...
@@ -40,7 +40,9 @@
---
If the value is empty or not defined (i.e. <<<<my-property/>>>>), the system property
is set with an empty String as the value.
is set with an empty String as the value. Maven trims values specified in the pom so it
is not possible to specify a System property who needs to start or end with a space via
this mechanism: consider using <<<jvmArguments>> instead.
Any String typed Maven variable can be passed as system properties. Any attempt to pass
any other Maven variable type (e.g. a <<<List>>> or a <<<URL>>> variable) will cause the
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/SystemPropertyFormatterTests.java
View file @
fd47b728
...
...
@@ -40,7 +40,7 @@ public class SystemPropertyFormatterTests {
@Test
public
void
parseKeyWithValue
()
{
assertThat
(
SystemPropertyFormatter
.
format
(
"key1"
,
"value1"
))
.
isEqualTo
(
"-Dkey1=
value1
"
);
.
isEqualTo
(
"-Dkey1=
\"value1\"
"
);
}
@Test
...
...
@@ -48,4 +48,10 @@ public class SystemPropertyFormatterTests {
assertThat
(
SystemPropertyFormatter
.
format
(
"key1"
,
""
)).
isEqualTo
(
"-Dkey1"
);
}
@Test
public
void
parseKeyWithOnlySpace
()
{
assertThat
(
SystemPropertyFormatter
.
format
(
"key1"
,
" "
))
.
isEqualTo
(
"-Dkey1=\" \""
);
}
}
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