diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 15102eec95..713f71bc5d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -78,10 +78,19 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { * Path to agent jar. NOTE: the use of agents means that processes will be started by * forking a new JVM. * @since 1.0 + * @deprecated since version 2.2. Use agents instead. */ @Parameter(property = "spring-boot.run.agent") private File[] agent; + /** + * Path to agent jars. NOTE: the use of agents means that processes will be started by + * forking a new JVM. + * @since 2.2 + */ + @Parameter(property = "spring-boot.run.agents") + private File[] agents; + /** * Flag to say that the agent requires -noverify. * @since 1.0 @@ -218,7 +227,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { } private boolean hasAgent() { - return (this.agent != null && this.agent.length > 0); + File[] configuredAgents = determineAgents(); + return (configuredAgents != null && configuredAgents.length > 0); } private boolean hasJvmArgs() { @@ -360,11 +370,12 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { } private void addAgents(List args) { - if (this.agent != null) { + File[] configuredAgents = determineAgents(); + if (configuredAgents != null) { if (getLog().isInfoEnabled()) { - getLog().info("Attaching agents: " + Arrays.asList(this.agent)); + getLog().info("Attaching agents: " + Arrays.asList(configuredAgents)); } - for (File agent : this.agent) { + for (File agent : configuredAgents) { args.add("-javaagent:" + agent); } } @@ -373,6 +384,11 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { } } + @SuppressWarnings("deprecation") + private File[] determineAgents() { + return (this.agents != null) ? this.agents : this.agent; + } + private void addActiveProfileArgument(RunArguments arguments) { if (this.profiles.length > 0) { StringBuilder arg = new StringBuilder("--spring.profiles.active=");