React to the Java plugin being applied rather than always applying it

pull/8686/merge
Andy Wilkinson 8 years ago
parent 9b15e6b5a3
commit 20fe95b276

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,6 @@ import org.gradle.api.Action;
import org.gradle.api.Plugin; import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.Task; import org.gradle.api.Task;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.compile.JavaCompile;
import org.springframework.boot.gradle.SpringBootPluginExtension; import org.springframework.boot.gradle.SpringBootPluginExtension;
@ -42,7 +41,6 @@ public class SpringBootPlugin implements Plugin<Project> {
public void apply(Project project) { public void apply(Project project) {
project.getExtensions().create("springBoot", SpringBootPluginExtension.class, project.getExtensions().create("springBoot", SpringBootPluginExtension.class,
project); project);
project.getPlugins().apply(JavaPlugin.class);
new AgentPluginFeatures().apply(project); new AgentPluginFeatures().apply(project);
new RepackagePluginFeatures().apply(project); new RepackagePluginFeatures().apply(project);
new RunPluginFeatures().apply(project); new RunPluginFeatures().apply(project);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -53,8 +53,10 @@ public class RepackagePluginFeatures implements PluginFeatures {
@Override @Override
public void apply(Project project) { public void apply(Project project) {
addRepackageTask(project); project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
registerRepackageTaskProperty(project); addRepackageTask(project);
registerRepackageTaskProperty(project);
});
} }
private void addRepackageTask(Project project) { private void addRepackageTask(Project project) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,6 +23,7 @@ import org.gradle.api.Action;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.Task; import org.gradle.api.Task;
import org.gradle.api.plugins.ExtraPropertiesExtension; import org.gradle.api.plugins.ExtraPropertiesExtension;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.application.CreateStartScripts; import org.gradle.api.tasks.application.CreateStartScripts;
@ -42,8 +43,10 @@ public class RunPluginFeatures implements PluginFeatures {
@Override @Override
public void apply(Project project) { public void apply(Project project) {
mainClassNameFinder(project); project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
addBootRunTask(project); mainClassNameFinder(project);
addBootRunTask(project);
});
} }
private void mainClassNameFinder(Project project) { private void mainClassNameFinder(Project project) {

Loading…
Cancel
Save