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