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
23e78103
Commit
23e78103
authored
Feb 20, 2020
by
Scott Frederick
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x'
Closes gh-20244
parents
e7c265bc
625b40aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
5 deletions
+85
-5
MavenBuild.java
...tTest/java/org/springframework/boot/maven/MavenBuild.java
+2
-0
RunIntegrationTests.java
...a/org/springframework/boot/maven/RunIntegrationTests.java
+26
-3
pom.xml
...ugin/src/intTest/projects/run-jvmargs-commandline/pom.xml
+22
-0
SampleApplication.java
...commandline/src/main/java/org/test/SampleApplication.java
+33
-0
AbstractRunMojo.java
.../java/org/springframework/boot/maven/AbstractRunMojo.java
+2
-2
No files found.
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/MavenBuild.java
View file @
23e78103
...
@@ -46,6 +46,7 @@ import org.apache.maven.shared.invoker.DefaultInvoker;
...
@@ -46,6 +46,7 @@ import org.apache.maven.shared.invoker.DefaultInvoker;
import
org.apache.maven.shared.invoker.InvocationRequest
;
import
org.apache.maven.shared.invoker.InvocationRequest
;
import
org.apache.maven.shared.invoker.InvocationResult
;
import
org.apache.maven.shared.invoker.InvocationResult
;
import
org.apache.maven.shared.invoker.Invoker
;
import
org.apache.maven.shared.invoker.Invoker
;
import
org.apache.maven.shared.invoker.InvokerLogger
;
import
org.apache.maven.shared.invoker.MavenInvocationException
;
import
org.apache.maven.shared.invoker.MavenInvocationException
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -184,6 +185,7 @@ class MavenBuild {
...
@@ -184,6 +185,7 @@ class MavenBuild {
buildLog
.
flush
();
buildLog
.
flush
();
});
});
try
{
try
{
invoker
.
getLogger
().
setThreshold
(
InvokerLogger
.
DEBUG
);
InvocationResult
result
=
invoker
.
execute
(
request
);
InvocationResult
result
=
invoker
.
execute
(
request
);
assertThat
(
result
.
getExitCode
()).
as
(
contentOf
(
buildLogFile
)).
isEqualTo
(
expectedExitCode
);
assertThat
(
result
.
getExitCode
()).
as
(
contentOf
(
buildLogFile
)).
isEqualTo
(
expectedExitCode
);
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/RunIntegrationTests.java
View file @
23e78103
...
@@ -71,7 +71,7 @@ class RunIntegrationTests {
...
@@ -71,7 +71,7 @@ class RunIntegrationTests {
}
}
@TestTemplate
@TestTemplate
void
whenSystemPropertiesAreConfiguredTheyAreAvailableToTheApplication
(
MavenBuild
mavenBuild
)
{
void
whenSystemPropertiesA
ndJvmArgumentsA
reConfiguredTheyAreAvailableToTheApplication
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"run-jvm-system-props"
).
goals
(
"spring-boot:run"
)
mavenBuild
.
project
(
"run-jvm-system-props"
).
goals
(
"spring-boot:run"
)
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
)).
contains
(
"I haz been run"
));
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
)).
contains
(
"I haz been run"
));
}
}
...
@@ -82,6 +82,20 @@ class RunIntegrationTests {
...
@@ -82,6 +82,20 @@ class RunIntegrationTests {
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
)).
contains
(
"I haz been run"
));
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
)).
contains
(
"I haz been run"
));
}
}
@TestTemplate
void
whenCommandLineSpecifiesJvmArgumentsTheyAreAvailableToTheApplication
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"run-jvmargs-commandline"
).
goals
(
"spring-boot:run"
)
.
systemProperty
(
"spring-boot.run.jvmArguments"
,
"\"-Dfoo=value1\" \"-Dbar=value2\""
)
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
)).
contains
(
"I haz been run"
));
}
@TestTemplate
void
whenPomAndCommandLineSpecifyJvmArgumentsThenPomOverrides
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"run-jvmargs"
).
goals
(
"spring-boot:run"
)
.
systemProperty
(
"spring-boot.run.jvmArguments"
,
"\"-Dfoo=value-from-cmd\""
)
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
)).
contains
(
"I haz been run"
));
}
@TestTemplate
@TestTemplate
void
whenProfilesAreConfiguredTheyArePassedToTheApplication
(
MavenBuild
mavenBuild
)
{
void
whenProfilesAreConfiguredTheyArePassedToTheApplication
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"run-profiles"
).
goals
(
"spring-boot:run"
,
"-X"
).
execute
(
mavenBuild
.
project
(
"run-profiles"
).
goals
(
"spring-boot:run"
,
"-X"
).
execute
(
...
@@ -102,8 +116,8 @@ class RunIntegrationTests {
...
@@ -102,8 +116,8 @@ class RunIntegrationTests {
@TestTemplate
@TestTemplate
void
whenAWorkingDirectoryIsConfiguredTheApplicationIsRunFromThatDirectory
(
MavenBuild
mavenBuild
)
{
void
whenAWorkingDirectoryIsConfiguredTheApplicationIsRunFromThatDirectory
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"run-working-directory"
).
goals
(
"spring-boot:run"
)
mavenBuild
.
project
(
"run-working-directory"
).
goals
(
"spring-boot:run"
)
.
execute
(
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
)).
contains
(
"I haz been run
"
));
(
project
)
->
assertThat
(
buildLog
(
project
)).
containsPattern
(
"I haz been run from.*/src/main/java
"
));
}
}
@TestTemplate
@TestTemplate
...
@@ -129,6 +143,15 @@ class RunIntegrationTests {
...
@@ -129,6 +143,15 @@ class RunIntegrationTests {
"I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info,health,metrics'"
));
"I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info,health,metrics'"
));
}
}
@TestTemplate
void
whenPomAndCommandLineSpecifyRunArgumentsThenPomOverrides
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"run-arguments"
).
goals
(
"spring-boot:run"
)
.
systemProperty
(
"spring-boot.run.arguments"
,
"--management.endpoints.web.exposure.include=one,two,three --spring.profiles.active=test"
)
.
execute
((
project
)
->
assertThat
(
buildLog
(
project
))
.
contains
(
"I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info'"
));
}
private
String
buildLog
(
File
project
)
{
private
String
buildLog
(
File
project
)
{
return
contentOf
(
new
File
(
project
,
"target/build.log"
));
return
contentOf
(
new
File
(
project
,
"target/build.log"
));
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-jvmargs-commandline/pom.xml
0 → 100644
View file @
23e78103
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.springframework.boot.maven.it
</groupId>
<artifactId>
run-jvmargs-commandline
</artifactId>
<version>
0.0.1.BUILD-SNAPSHOT
</version>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
@java.version@
</maven.compiler.source>
<maven.compiler.target>
@java.version@
</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>
@project.groupId@
</groupId>
<artifactId>
@project.artifactId@
</artifactId>
<version>
@project.version@
</version>
</plugin>
</plugins>
</build>
</project>
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/run-jvmargs-commandline/src/main/java/org/test/SampleApplication.java
0 → 100644
View file @
23e78103
/*
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
test
;
public
class
SampleApplication
{
public
static
void
main
(
String
[]
args
)
{
String
foo
=
System
.
getProperty
(
"foo"
);
if
(!
"value1"
.
equals
(
foo
))
{
throw
new
IllegalStateException
(
"foo system property mismatch (got ["
+
foo
+
"]"
);
}
String
bar
=
System
.
getProperty
(
"bar"
);
if
(!
"value2"
.
equals
(
bar
))
{
throw
new
IllegalStateException
(
"bar system property mismatch (got ["
+
bar
+
"]"
);
}
System
.
out
.
println
(
"I haz been run"
);
}
}
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java
View file @
23e78103
...
@@ -317,8 +317,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
...
@@ -317,8 +317,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
* @return a {@link RunArguments} defining the application arguments
* @return a {@link RunArguments} defining the application arguments
*/
*/
protected
RunArguments
resolveApplicationArguments
()
{
protected
RunArguments
resolveApplicationArguments
()
{
RunArguments
runArguments
=
(
this
.
commandlineArguments
!=
null
)
?
new
RunArguments
(
this
.
commandlineA
rguments
)
RunArguments
runArguments
=
(
this
.
arguments
!=
null
)
?
new
RunArguments
(
this
.
a
rguments
)
:
new
RunArguments
(
this
.
a
rguments
);
:
new
RunArguments
(
this
.
commandlineA
rguments
);
addActiveProfileArgument
(
runArguments
);
addActiveProfileArgument
(
runArguments
);
return
runArguments
;
return
runArguments
;
}
}
...
...
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