-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to configure POM for ZIP publication #3252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,15 +37,27 @@ public static void configMaven(Project project) { | |
}); | ||
}); | ||
publishing.publications(publications -> { | ||
publications.create(PUBLICATION_NAME, MavenPublication.class, mavenZip -> { | ||
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(); | ||
String zipVersion = getProperty("version", project); | ||
mavenZip.artifact(project.getTasks().named("bundlePlugin")); | ||
mavenZip.setGroupId(zipGroup); | ||
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 @@ static String getProperty(String name, Project 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 void apply(Project project) { | |
} | ||
Task publishPluginZipPublicationToZipStagingRepository = project.getTasks() | ||
.findByName("publishPluginZipPublicationToZipStagingRepository"); | ||
if (validatePluginZipPom != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we might still need this @reta
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The This condition should be for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol my bad, this formatting looks like it was removed, yes I can see those 2 conditions are not touched. |
||
project.getTasks() | ||
.getByName("publishPluginZipPublicationToZipStagingRepository") | ||
.dependsOn("generatePomFileForNebulaPublication"); | ||
if (publishPluginZipPublicationToZipStagingRepository != null) { | ||
publishPluginZipPublicationToZipStagingRepository.dependsOn("generatePomFileForNebulaPublication"); | ||
} | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reta we need this if/else condition so that user can declare a publication of
pluginZip
and pom fields ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes