Gradle plugin `opensearch.pluginzip` Add implicit dependency. (#3189)
* Add implicit dependency Signed-off-by: pgodithi <pgodithi@amazon.com> * Add implicit dependency Signed-off-by: pgodithi <pgodithi@amazon.com> * Add implicit dependency Signed-off-by: pgodithi <pgodithi@amazon.com> * Add implicit dependency Signed-off-by: pgodithi <pgodithi@amazon.com> * Add implicit dependency Signed-off-by: pgodithi <pgodithi@amazon.com> * Add implicit dependency Signed-off-by: pgodithi <pgodithi@amazon.com> * Add dependsOn Signed-off-by: pgodithi <pgodithi@amazon.com>
This commit is contained in:
parent
c41b41140b
commit
2fe2e37a44
|
@ -135,11 +135,11 @@ public class PublishPlugin implements Plugin<Project> {
|
|||
publication.artifact(project.getTasks().getByName("sourcesJar"));
|
||||
publication.artifact(project.getTasks().getByName("javadocJar"));
|
||||
}
|
||||
}
|
||||
|
||||
generatePomTask.configure(
|
||||
t -> t.dependsOn(String.format("generatePomFileFor%sPublication", Util.capitalize(publication.getName())))
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.gradle.api.publish.PublishingExtension;
|
|||
import org.gradle.api.publish.maven.MavenPublication;
|
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
|
||||
import java.nio.file.Path;
|
||||
import org.gradle.api.Task;
|
||||
|
||||
public class Publish implements Plugin<Project> {
|
||||
private Project project;
|
||||
|
@ -63,12 +64,19 @@ public class Publish implements Plugin<Project> {
|
|||
@Override
|
||||
public void apply(Project project) {
|
||||
this.project = project;
|
||||
project.afterEvaluate(evaluatedProject -> { configMaven(project); });
|
||||
project.getGradle().getTaskGraph().whenReady(graph -> {
|
||||
if (graph.hasTask(LOCALMAVEN)) {
|
||||
project.getTasks().getByName(PLUGIN_ZIP_PUBLISH_POM_TASK).setEnabled(false);
|
||||
project.afterEvaluate(evaluatedProject -> {
|
||||
configMaven(project);
|
||||
Task validatePluginZipPom = project.getTasks().findByName("validatePluginZipPom");
|
||||
if (validatePluginZipPom != null) {
|
||||
project.getTasks().getByName("validatePluginZipPom").dependsOn("generatePomFileForNebulaPublication");
|
||||
}
|
||||
Task publishPluginZipPublicationToZipStagingRepository = project.getTasks()
|
||||
.findByName("publishPluginZipPublicationToZipStagingRepository");
|
||||
if (validatePluginZipPom != null) {
|
||||
project.getTasks()
|
||||
.getByName("publishPluginZipPublicationToZipStagingRepository")
|
||||
.dependsOn("generatePomFileForNebulaPublication");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
import java.io.FileReader;
|
||||
import org.gradle.api.tasks.bundling.Zip;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PublishTests extends GradleUnitTestCase {
|
||||
|
||||
|
@ -56,6 +58,7 @@ public class PublishTests extends GradleUnitTestCase {
|
|||
writeString(new File(projectDir, "settings.gradle"), "");
|
||||
// Generate the build.gradle file
|
||||
String buildFileContent = "apply plugin: 'maven-publish' \n"
|
||||
+ "apply plugin: 'java' \n"
|
||||
+ "publishing {\n"
|
||||
+ " repositories {\n"
|
||||
+ " maven {\n"
|
||||
|
@ -74,10 +77,13 @@ public class PublishTests extends GradleUnitTestCase {
|
|||
+ "}";
|
||||
writeString(new File(projectDir, "build.gradle"), buildFileContent);
|
||||
// Execute the task publishPluginZipPublicationToZipStagingRepository
|
||||
List<String> allArguments = new ArrayList<String>();
|
||||
allArguments.add("build");
|
||||
allArguments.add(zipPublishTask);
|
||||
GradleRunner runner = GradleRunner.create();
|
||||
runner.forwardOutput();
|
||||
runner.withPluginClasspath();
|
||||
runner.withArguments(zipPublishTask);
|
||||
runner.withArguments(allArguments);
|
||||
runner.withProjectDir(projectDir);
|
||||
BuildResult result = runner.build();
|
||||
// Check if task publishMavenzipPublicationToZipstagingRepository has ran well
|
||||
|
@ -87,6 +93,7 @@ public class PublishTests extends GradleUnitTestCase {
|
|||
new File("build/functionalTest/local-staging-repo/org/opensearch/plugin/sample-plugin/2.0.0.0/sample-plugin-2.0.0.0.zip")
|
||||
.exists()
|
||||
);
|
||||
assertEquals(SUCCESS, result.task(":" + "build").getOutcome());
|
||||
// Parse the maven file and validate the groupID to org.opensearch.plugin
|
||||
MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
Model model = reader.read(
|
||||
|
|
Loading…
Reference in New Issue