Allow to configure POM for ZIP publication (#3252)
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
This commit is contained in:
parent
132eabd675
commit
f5c0b30a8e
|
@ -7,18 +7,17 @@
|
|||
*/
|
||||
package org.opensearch.gradle.pluginzip;
|
||||
|
||||
import java.util.*;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.publish.Publication;
|
||||
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;
|
||||
|
||||
public final static String EXTENSION_NAME = "zipmavensettings";
|
||||
public final static String PUBLICATION_NAME = "pluginZip";
|
||||
public final static String STAGING_REPO = "zipStaging";
|
||||
|
@ -38,6 +37,8 @@ public class Publish implements Plugin<Project> {
|
|||
});
|
||||
});
|
||||
publishing.publications(publications -> {
|
||||
final Publication publication = publications.findByName(PUBLICATION_NAME);
|
||||
if (publication == null) {
|
||||
publications.create(PUBLICATION_NAME, MavenPublication.class, mavenZip -> {
|
||||
String zipGroup = "org.opensearch.plugin";
|
||||
String zipArtifact = project.getName();
|
||||
|
@ -47,6 +48,16 @@ public class Publish implements Plugin<Project> {
|
|||
mavenZip.setArtifactId(zipArtifact);
|
||||
mavenZip.setVersion(zipVersion);
|
||||
});
|
||||
} else {
|
||||
final MavenPublication mavenZip = (MavenPublication) publication;
|
||||
String zipGroup = "org.opensearch.plugin";
|
||||
String zipArtifact = project.getName();
|
||||
String zipVersion = getProperty("version", project);
|
||||
mavenZip.artifact(project.getTasks().named("bundlePlugin"));
|
||||
mavenZip.setGroupId(zipGroup);
|
||||
mavenZip.setArtifactId(zipArtifact);
|
||||
mavenZip.setVersion(zipVersion);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -63,7 +74,6 @@ public class Publish implements Plugin<Project> {
|
|||
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
this.project = project;
|
||||
project.afterEvaluate(evaluatedProject -> {
|
||||
configMaven(project);
|
||||
Task validatePluginZipPom = project.getTasks().findByName("validatePluginZipPom");
|
||||
|
@ -72,10 +82,8 @@ public class Publish implements Plugin<Project> {
|
|||
}
|
||||
Task publishPluginZipPublicationToZipStagingRepository = project.getTasks()
|
||||
.findByName("publishPluginZipPublicationToZipStagingRepository");
|
||||
if (validatePluginZipPom != null) {
|
||||
project.getTasks()
|
||||
.getByName("publishPluginZipPublicationToZipStagingRepository")
|
||||
.dependsOn("generatePomFileForNebulaPublication");
|
||||
if (publishPluginZipPublicationToZipStagingRepository != null) {
|
||||
publishPluginZipPublicationToZipStagingRepository.dependsOn("generatePomFileForNebulaPublication");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.gradle.testkit.runner.GradleRunner;
|
|||
import org.gradle.testfixtures.ProjectBuilder;
|
||||
import org.gradle.api.Project;
|
||||
import org.opensearch.gradle.test.GradleUnitTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
@ -31,7 +32,6 @@ 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 org.gradle.internal.impldep.org.junit.After;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
|
Loading…
Reference in New Issue