diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/agent/AgentPluginFeatures.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/agent/AgentPluginFeatures.java deleted file mode 100644 index 024d9d5fae..0000000000 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/agent/AgentPluginFeatures.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012-2015 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 - * - * http://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.springframework.boot.gradle.agent; - -import org.gradle.api.Project; - -import org.springframework.boot.gradle.PluginFeatures; - -/** - * {@link PluginFeatures} to add Java Agent support. - * - * @author Phillip Webb - */ -public class AgentPluginFeatures implements PluginFeatures { - - @Override - public void apply(Project project) { - project.afterEvaluate(new AgentTasksEnhancer()); - } - -} diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/agent/AgentTasksEnhancer.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/agent/AgentTasksEnhancer.java deleted file mode 100644 index 77b5447df6..0000000000 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/agent/AgentTasksEnhancer.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2012-2015 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 - * - * http://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.springframework.boot.gradle.agent; - -import java.io.File; -import java.net.URISyntaxException; -import java.security.CodeSource; - -import org.gradle.api.Action; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.tasks.JavaExec; - -import org.springframework.boot.gradle.SpringBootPluginExtension; - -/** - * Add a java agent to the "run" task if configured. You can add an agent in 3 ways (4 if - * you want to use native gradle features as well): - * - *
    - *
  1. Use "-Prun.agent=[path-to-jar]" on the gradle command line
  2. - *
  3. Add an "agent" property (jar file) to the "springBoot" extension in build.gradle - *
  4. - *
  5. As a special case springloaded is detected as a build script dependency
  6. - *
- * - * @author Dave Syer - * @author Phillip Webb - */ -public class AgentTasksEnhancer implements Action { - - private static final String SPRING_LOADED_AGENT_CLASS_NAME = "org.springsource.loaded.agent.SpringLoadedAgent"; - - private File agent; - - private Boolean noverify; - - @Override - public void execute(Project project) { - setup(project); - if (this.agent != null) { - for (Task task : project.getTasks()) { - addAgent(project, task); - } - } - } - - private void setup(Project project) { - project.getLogger().info("Configuring agent"); - SpringBootPluginExtension extension = project.getExtensions() - .getByType(SpringBootPluginExtension.class); - this.noverify = extension.getNoverify(); - this.agent = getAgent(project, extension); - if (this.agent == null) { - this.agent = getSpringLoadedAgent(); - if (this.noverify == null) { - this.noverify = true; - } - } - project.getLogger().debug("Agent: " + this.agent); - } - - private File getAgent(Project project, SpringBootPluginExtension extension) { - if (project.hasProperty("run.agent")) { - return project.file(project.property("run.agent")); - } - return extension.getAgent(); - } - - private File getSpringLoadedAgent() { - try { - Class loaded = Class.forName(SPRING_LOADED_AGENT_CLASS_NAME); - if (loaded != null) { - CodeSource source = loaded.getProtectionDomain().getCodeSource(); - if (source != null) { - try { - return new File(source.getLocation().toURI()); - } - catch (URISyntaxException ex) { - return new File(source.getLocation().getPath()); - } - } - } - } - catch (ClassNotFoundException ex) { - // ignore; - } - return null; - } - - private void addAgent(Project project, Task task) { - if (task instanceof JavaExec) { - addAgent(project, (JavaExec) task); - } - } - - private void addAgent(Project project, JavaExec exec) { - project.getLogger().debug("Attaching to: " + exec); - if (this.agent != null) { - project.getLogger().info("Attaching agent: " + this.agent); - exec.jvmArgs("-javaagent:" + this.agent.getAbsolutePath()); - if (this.noverify != null && this.noverify) { - exec.jvmArgs("-noverify"); - } - Iterable defaultJvmArgs = exec.getConventionMapping() - .getConventionValue(null, "jvmArgs", false); - if (defaultJvmArgs != null) { - exec.jvmArgs(defaultJvmArgs); - } - } - } - -} diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java index 7b1efcb8f4..67efd9754c 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java @@ -23,7 +23,6 @@ import org.gradle.api.Task; import org.gradle.api.tasks.compile.JavaCompile; import org.springframework.boot.gradle.SpringBootPluginExtension; -import org.springframework.boot.gradle.agent.AgentPluginFeatures; import org.springframework.boot.gradle.application.ApplicationPluginFeatures; import org.springframework.boot.gradle.bundling.BundlingPluginFeatures; import org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures; @@ -42,7 +41,6 @@ public class SpringBootPlugin implements Plugin { public void apply(Project project) { project.getExtensions().create("springBoot", SpringBootPluginExtension.class, project); - new AgentPluginFeatures().apply(project); new ApplicationPluginFeatures().apply(project); new BundlingPluginFeatures().apply(project); new RunPluginFeatures().apply(project);