-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Fix multi jar publishing #32195
Fix multi jar publishing #32195
Conversation
Versions of Gradle before 4.9 don't support project that depend on other projects which have multiple jar publications, see gradle/gradle#1061. It just so happens that we upgraded master and 6.x to 4.9 recently, but 6.3 is still on Gradle 4.5 so the multi publications will break there. This change removes the client jar publication, since now the artifactId is the only one that differes, and adds the nebula configuration to the plugin so we don't rely on it's presence in the build scipt to generate a correct pom. Without the plugin applied, the generated dependencies would be empty.
Pinging @elastic/es-core-infra |
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.
The generated POM looks good to me. I left some minor questions about the gradle changes.
@@ -69,16 +65,16 @@ public class PluginBuildPlugin extends BuildPlugin { | |||
String name = project.pluginProperties.extension.name | |||
project.archivesBaseName = name | |||
|
|||
// while the jar isn't normally published, we still at least build a pom of deps |
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.
I think we should mention x-pack-core here explicitly.
@@ -23,6 +23,7 @@ | |||
* fix the hack in the build framework that copies transport-netty4 into the integ test cluster | |||
* maybe figure out a way to run all tests from core with netty4/network? | |||
*/ | |||
|
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.
Probably worth reverting this one.
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.
Git annotate says these were added by @jasontedor, I'm happy to help with it.
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.
I misread this to mean "revisiting" and taught it's about the TODO above ... will revert
.parse(project.tasks.generatePomFileForNebulaPublication.outputs.files.singleFile) | ||
pom.artifactId[0].value = project.name + "-client" | ||
jarFile.resolveSibling(clientPomFileName).toFile().text = XmlUtil.serialize(pom) | ||
// Groovy has an odd way of formatting the XML, fix it up3 |
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.
extra 3
?
/** Adds a task to move jar and associated files to a "-client" name. */ | ||
protected static void addClientJarTask(Project project) { | ||
Task clientJar = project.tasks.create('clientJar') | ||
clientJar.dependsOn(project.jar, project.tasks.generatePomFileForClientJarPublication, project.javadocJar, project.sourcesJar) | ||
clientJar.dependsOn(project.jar, project.tasks.generatePomFileForNebulaPublication, project.javadocJar, project.sourcesJar) | ||
clientJar.doFirst { | ||
Path jarFile = project.jar.outputs.files.singleFile.toPath() | ||
String clientFileName = jarFile.fileName.toString().replace(project.version, "client-${project.version}") |
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.
It'd be nice if this were declare an output. I know it didn't have it before though.
@@ -169,21 +165,42 @@ public class PluginBuildPlugin extends BuildPlugin { | |||
project.artifacts.add('zip', bundle) | |||
} | |||
|
|||
/** Find the reponame. */ | |||
static String urlFromOrigin(String origin) { |
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.
Is this still used?
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, by a build script at distribution/archives/build.gradle we could probably have that use nebula and clean it up, but didn't want to get into that now.
This commit fixes the build for 6.3 after the backport of #32180. First, the meta plugin build no longer needed to call zip pom generation. Second, pom generation for the jar needs to only happen when not building a client jar, because gradle versions before 4.9 get confused with multiple versions of the same artifact (see #32195).
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.
I'm not sure we actually need this, given there is a workaround (only have client jar or normal jar+pom). Given we don't currently have a need for both, is there any reason not to just apply the same tweak (add back the else condition for configuring the jar pom)?
@rjernst I'm ok with moving jar generation so it doesn't happen at the same time with client jar. I do think we need to keep from this PR the part about applying nebula, as it is it's too easy to forget that and don't see a reason to rely on the build script to apply it rather than doing it in the plugin. |
Publishing is a choice. Plugin authors could be publishing their plugins in many ways. This let's them choose if they want to use nebula. For all the stuff that build-tools pulls in for plugin development, all of it is optional (the tasks can be disabled). AFAIK, publishing is not something that can simply be disabled, because the tasks are generated late and not available when the plugin is applied. |
We don't have to pull in Nebula, but we do already pull in Publishing, so I would expect that either we don't generate any pom, or generate a correct one out of the box. Without this change we will generate a pom that doesn't have dependencies. That doesn't feel right. I very much like your statement: "publishing is a choice". I will check to see if we can avoid applying the publishing plugin. Maybe have the publishing just for the build scripts where we need it and avoid dealing with it in the plugin. Also in Gradle 4.9 with stable publishing ( which we enable ) the tasks might no longer be created that late. |
I suspect the fact we always pull in publishing and generate a pom is leftover from the very first iteration of gradle, when we were still always publishing plugin zips to maven. Since we don't do this anymore (and haven't since 5.0 beta), we should change this to only create a pom if configured. |
Closing in favor of #32351 |
Versions of Gradle before 4.9 don't support project that depend on other
projects which have multiple jar publications, see gradle/gradle#1061.
It just so happens that we upgraded master and 6.x to 4.9 recently, but
6.3 is still on Gradle 4.5 so the multi publications will break there.
This change removes the client jar publication, since now the artifactId
is the only one that differes, and adds the nebula configuration to the
plugin so we don't rely on it's presence in the build scipt to generate
a correct pom. Without the plugin applied, the generated dependencies
would be empty.
Relates #31946