From f4fbc3e33955c34aae21e93d8b235d9914213080 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 15 Dec 2014 13:08:17 -0800 Subject: [PATCH] Fix Maven Spring Loaded detection logic Ensure that the Maven plugin RunMojo attempts to detect the Spring Loaded agent before deciding if the JVM should be forked. Fixes gh-2140 --- .../main/java/org/springframework/boot/maven/RunMojo.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java index ec7dd626ab..e30a4cc796 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunMojo.java @@ -168,8 +168,10 @@ public class RunMojo extends AbstractDependencyFilterMojo { } private void run(String startClassName) throws MojoExecutionException { - if (this.fork || (this.agent != null && this.agent.length > 0) - || (this.jvmArguments != null && this.jvmArguments.length() > 0)) { + findAgent(); + boolean hasAgent = (this.agent != null && this.agent.length > 0); + boolean hasJvmArgs = (this.jvmArguments != null && this.jvmArguments.length() > 0); + if (this.fork || hasAgent || hasJvmArgs) { runWithForkedJvm(startClassName); } else { @@ -204,7 +206,6 @@ public class RunMojo extends AbstractDependencyFilterMojo { } private void addAgents(List args) { - findAgent(); if (this.agent != null) { getLog().info("Attaching agents: " + Arrays.asList(this.agent)); for (File agent : this.agent) {