Merge branch '2.5.x' into 2.6.x

Closes gh-30835
pull/30839/head
Andy Wilkinson 3 years ago
commit de1cda786e

@ -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<Project> {
.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<Project> {
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<Project> {
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<Project> {
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<Project> {
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<Project> {
.map((dir) -> dir.file("extracted-versions.properties")));
}
public static class FormatHelpMojoSourceTask extends DefaultTask {
public static class FormatHelpMojoSource extends DefaultTask {
private Task generator;

Loading…
Cancel
Save