diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java index d5bf4099b8..b41df2abb3 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java @@ -69,7 +69,6 @@ import org.gradle.api.publish.PublishingExtension; import org.gradle.api.publish.maven.MavenPublication; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; import org.gradle.api.tasks.Classpath; -import org.gradle.api.tasks.Copy; import org.gradle.api.tasks.InputFiles; import org.gradle.api.tasks.JavaExec; import org.gradle.api.tasks.OutputDirectory; @@ -78,6 +77,7 @@ import org.gradle.api.tasks.PathSensitive; import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; +import org.gradle.api.tasks.Sync; import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.TaskExecutionException; import org.gradle.api.tasks.bundling.Jar; @@ -154,7 +154,7 @@ public class MavenPluginPlugin implements Plugin { .set(new File(project.getBuildDir(), "runtime-classpath-repository")); project.getDependencies() .components((components) -> components.all(MavenRepositoryComponentMetadataRule.class)); - Copy task = project.getTasks().create("populateIntTestMavenRepository", Copy.class); + Sync task = project.getTasks().create("populateIntTestMavenRepository", Sync.class); task.setDestinationDir(new File(project.getBuildDir(), "int-test-maven-repository")); task.with(copyIntTestMavenRepositoryFiles(project, runtimeClasspathMavenRepository)); task.dependsOn(project.getTasks().getByName(MavenRepositoryPlugin.PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME)); @@ -181,7 +181,7 @@ public class MavenPluginPlugin implements Plugin { private MavenExec addGenerateHelpMojoTask(Project project, Jar jarTask) { File helpMojoDir = new File(project.getBuildDir(), "help-mojo"); MavenExec task = createGenerateHelpMojoTask(project, helpMojoDir); - task.dependsOn(createCopyHelpMojoInputsTask(project, helpMojoDir)); + task.dependsOn(createSyncHelpMojoInputsTask(project, helpMojoDir)); includeHelpMojoInJar(jarTask, task); return task; } @@ -194,8 +194,8 @@ public class MavenPluginPlugin implements Plugin { return task; } - private Copy createCopyHelpMojoInputsTask(Project project, File helpMojoDir) { - Copy task = project.getTasks().create("copyHelpMojoInputs", Copy.class); + private Sync createSyncHelpMojoInputsTask(Project project, File helpMojoDir) { + Sync task = project.getTasks().create("syncHelpMojoInputs", Sync.class); task.setDestinationDir(helpMojoDir); File pomFile = new File(project.getProjectDir(), "src/maven/resources/pom.xml"); task.from(pomFile, (copy) -> replaceVersionPlaceholder(copy, project)); @@ -212,11 +212,11 @@ public class MavenPluginPlugin implements Plugin { File generatedHelpMojoDir = new File(project.getBuildDir(), "generated/sources/helpMojo"); SourceSet mainSourceSet = getMainSourceSet(project); project.getTasks().withType(Javadoc.class, this::setJavadocOptions); - FormatHelpMojoSourceTask copyFormattedHelpMojoSourceTask = createCopyFormattedHelpMojoSourceTask(project, + FormatHelpMojoSource copyFormattedHelpMojoSourceTask = createFormatHelpMojoSourceTask(project, generateHelpMojoTask, generatedHelpMojoDir); project.getTasks().getByName(mainSourceSet.getCompileJavaTaskName()).dependsOn(copyFormattedHelpMojoSourceTask); mainSourceSet.java((javaSources) -> javaSources.srcDir(copyFormattedHelpMojoSourceTask)); - Copy pluginDescriptorInputs = createCopyPluginDescriptorInputs(project, pluginDescriptorDir, mainSourceSet); + Sync pluginDescriptorInputs = createSyncPluginDescriptorInputs(project, pluginDescriptorDir, mainSourceSet); pluginDescriptorInputs.dependsOn(mainSourceSet.getClassesTaskName()); MavenExec task = createGeneratePluginDescriptorTask(project, pluginDescriptorDir); task.dependsOn(pluginDescriptorInputs); @@ -234,17 +234,17 @@ public class MavenPluginPlugin implements Plugin { options.addMultilineStringsOption("tag").setValue(Arrays.asList("goal:X", "requiresProject:X", "threadSafe:X")); } - private FormatHelpMojoSourceTask createCopyFormattedHelpMojoSourceTask(Project project, - MavenExec generateHelpMojoTask, File generatedHelpMojoDir) { - FormatHelpMojoSourceTask copyFormattedHelpMojoSourceTask = project.getTasks() - .create("copyFormattedHelpMojoSource", FormatHelpMojoSourceTask.class); - copyFormattedHelpMojoSourceTask.setGenerator(generateHelpMojoTask); - copyFormattedHelpMojoSourceTask.setOutputDir(generatedHelpMojoDir); - return copyFormattedHelpMojoSourceTask; + private FormatHelpMojoSource createFormatHelpMojoSourceTask(Project project, MavenExec generateHelpMojoTask, + File generatedHelpMojoDir) { + FormatHelpMojoSource formatHelpMojoSource = project.getTasks().create("formatHelpMojoSource", + FormatHelpMojoSource.class); + formatHelpMojoSource.setGenerator(generateHelpMojoTask); + formatHelpMojoSource.setOutputDir(generatedHelpMojoDir); + return formatHelpMojoSource; } - private Copy createCopyPluginDescriptorInputs(Project project, File destination, SourceSet sourceSet) { - Copy pluginDescriptorInputs = project.getTasks().create("copyPluginDescriptorInputs", Copy.class); + private Sync createSyncPluginDescriptorInputs(Project project, File destination, SourceSet sourceSet) { + Sync pluginDescriptorInputs = project.getTasks().create("copyPluginDescriptorInputs", Sync.class); pluginDescriptorInputs.setDestinationDir(destination); File pomFile = new File(project.getProjectDir(), "src/maven/resources/pom.xml"); pluginDescriptorInputs.from(pomFile, (copy) -> replaceVersionPlaceholder(copy, project)); @@ -291,7 +291,7 @@ public class MavenPluginPlugin implements Plugin { .map((dir) -> dir.file("extracted-versions.properties"))); } - public static class FormatHelpMojoSourceTask extends DefaultTask { + public static class FormatHelpMojoSource extends DefaultTask { private Task generator;