-
Notifications
You must be signed in to change notification settings - Fork 25.3k
[Build] Add support for publishing to maven central #128659
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
Changes from all commits
c87f6dd
959b5fb
20982c3
09edc9d
7a7b570
49f0c47
970792c
9f4ba3d
3312fc0
e948e31
f26d5b6
56bdc32
d6fae97
cd132af
6d2d072
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -26,8 +26,8 @@ group = "org.elasticsearch" | ||
|
|
||
// This project contains Checkstyle rule implementations used by IDEs which use a Java 11 runtime | // This project contains Checkstyle rule implementations used by IDEs which use a Java 11 runtime | ||
java { | java { | ||
targetCompatibility = 11 | targetCompatibility = 17 | ||
sourceCompatibility = 11 | sourceCompatibility = 17 | ||
} | } | ||
|
|
||
gradlePlugin { | gradlePlugin { | ||
|
@@ -75,6 +75,7 @@ dependencies { | ||
api buildLibs.maven.model | api buildLibs.maven.model | ||
api buildLibs.shadow.plugin | api buildLibs.shadow.plugin | ||
api buildLibs.apache.rat | api buildLibs.apache.rat | ||
api buildLibs.nmcp | |||
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. required by the PublishPlugin |
|||
compileOnly buildLibs.checkstyle | compileOnly buildLibs.checkstyle | ||
constraints { | constraints { | ||
api("org.eclipse.platform:org.eclipse.osgi:3.18.300") { | api("org.eclipse.platform:org.eclipse.osgi:3.18.300") { | ||
|
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -14,6 +14,8 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension; | import com.github.jengelman.gradle.plugins.shadow.ShadowExtension; | ||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin; | import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin; | ||
|
|
||
import nmcp.NmcpPlugin; | |||
|
|||
import org.elasticsearch.gradle.internal.conventions.info.GitInfo; | import org.elasticsearch.gradle.internal.conventions.info.GitInfo; | ||
import org.elasticsearch.gradle.internal.conventions.precommit.PomValidationPrecommitPlugin; | import org.elasticsearch.gradle.internal.conventions.precommit.PomValidationPrecommitPlugin; | ||
import org.elasticsearch.gradle.internal.conventions.util.Util; | import org.elasticsearch.gradle.internal.conventions.util.Util; | ||
|
@@ -27,6 +29,7 @@ | ||
import org.gradle.api.plugins.ExtensionContainer; | import org.gradle.api.plugins.ExtensionContainer; | ||
import org.gradle.api.plugins.JavaLibraryPlugin; | import org.gradle.api.plugins.JavaLibraryPlugin; | ||
import org.gradle.api.plugins.JavaPlugin; | import org.gradle.api.plugins.JavaPlugin; | ||
import org.gradle.api.plugins.JavaPluginExtension; | |||
import org.gradle.api.provider.MapProperty; | import org.gradle.api.provider.MapProperty; | ||
import org.gradle.api.provider.Provider; | import org.gradle.api.provider.Provider; | ||
import org.gradle.api.provider.ProviderFactory; | import org.gradle.api.provider.ProviderFactory; | ||
|
@@ -65,6 +68,7 @@ public void apply(Project project) { | ||
project.getPluginManager().apply(MavenPublishPlugin.class); | project.getPluginManager().apply(MavenPublishPlugin.class); | ||
project.getPluginManager().apply(PomValidationPrecommitPlugin.class); | project.getPluginManager().apply(PomValidationPrecommitPlugin.class); | ||
project.getPluginManager().apply(LicensingPlugin.class); | project.getPluginManager().apply(LicensingPlugin.class); | ||
project.getPluginManager().apply(NmcpPlugin.class); | |||
configureJavadocJar(project); | configureJavadocJar(project); | ||
configureSourcesJar(project); | configureSourcesJar(project); | ||
configurePomGeneration(project); | configurePomGeneration(project); | ||
|
@@ -82,6 +86,11 @@ private void configurePublications(Project project) { | ||
publication.from(project.getComponents().getByName("java")); | publication.from(project.getComponents().getByName("java")); | ||
} | } | ||
}); | }); | ||
project.getPlugins().withType(JavaPlugin.class, plugin -> { | |||
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. Ensure we include sources and javadoc jars as maven artifacts |
|||
var javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class); | |||
javaPluginExtension.withJavadocJar(); | |||
javaPluginExtension.withSourcesJar(); | |||
}); | |||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||
var projectLicenses = (MapProperty<String, Provider<String>>) project.getExtensions().getExtraProperties().get("projectLicenses"); | var projectLicenses = (MapProperty<String, Provider<String>>) project.getExtensions().getExtraProperties().get("projectLicenses"); | ||
publication.getPom().withXml(xml -> { | publication.getPom().withXml(xml -> { | ||
|
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -123,8 +123,6 @@ class BuildPluginFuncTest extends AbstractGradleFuncTest { | ||
then: | then: | ||
result.task(":assemble").outcome == TaskOutcome.SUCCESS | result.task(":assemble").outcome == TaskOutcome.SUCCESS | ||
file("build/distributions/hello-world.jar").exists() | file("build/distributions/hello-world.jar").exists() | ||
file("build/distributions/hello-world-javadoc.jar").exists() | |||
file("build/distributions/hello-world-sources.jar").exists() | |||
Comment on lines
-126
to
-127
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. Why are these files no longer produced? I couldn't pinpoint the change which disable that. 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. Its related to removing the publish plugin from the build plugin. see #128659 (comment) And there's now better PublishPlugin test coverage for this in PublishPluginFunc |
|||
assertValidJar(file("build/distributions/hello-world.jar")) | assertValidJar(file("build/distributions/hello-world.jar")) | ||
} | } | ||
|
|
||
|
@@ -162,7 +160,6 @@ class BuildPluginFuncTest extends AbstractGradleFuncTest { | ||
result.task(":forbiddenPatterns").outcome == TaskOutcome.SUCCESS | result.task(":forbiddenPatterns").outcome == TaskOutcome.SUCCESS | ||
result.task(":validateModule").outcome == TaskOutcome.SUCCESS | result.task(":validateModule").outcome == TaskOutcome.SUCCESS | ||
result.task(":splitPackagesAudit").outcome == TaskOutcome.SUCCESS | result.task(":splitPackagesAudit").outcome == TaskOutcome.SUCCESS | ||
result.task(":validateElasticPom").outcome == TaskOutcome.SUCCESS | |||
// disabled but check for being on the task graph | // disabled but check for being on the task graph | ||
result.task(":forbiddenApisMain").outcome == TaskOutcome.SKIPPED | result.task(":forbiddenApisMain").outcome == TaskOutcome.SKIPPED | ||
result.task(":checkstyleMain").outcome == TaskOutcome.SKIPPED | result.task(":checkstyleMain").outcome == TaskOutcome.SKIPPED | ||
|
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -9,6 +9,7 @@ | ||
|
|
||
package org.elasticsearch.gradle.internal; | package org.elasticsearch.gradle.internal; | ||
|
|
||
import org.elasticsearch.gradle.internal.conventions.LicensingPlugin; | |||
import org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin; | import org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin; | ||
import org.elasticsearch.gradle.internal.precommit.InternalPrecommitTasks; | import org.elasticsearch.gradle.internal.precommit.InternalPrecommitTasks; | ||
import org.elasticsearch.gradle.internal.snyk.SnykDependencyMonitoringGradlePlugin; | import org.elasticsearch.gradle.internal.snyk.SnykDependencyMonitoringGradlePlugin; | ||
|
@@ -59,9 +60,9 @@ public void apply(final Project project) { | ||
} | } | ||
|
|
||
project.getPluginManager().apply("elasticsearch.java"); | project.getPluginManager().apply("elasticsearch.java"); | ||
project.getPluginManager().apply("elasticsearch.publish"); | |||
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 should not apply the publish plugin by default when applying the build plugin:
|
|||
project.getPluginManager().apply(ElasticsearchJavadocPlugin.class); | project.getPluginManager().apply(ElasticsearchJavadocPlugin.class); | ||
project.getPluginManager().apply(DependenciesInfoPlugin.class); | project.getPluginManager().apply(DependenciesInfoPlugin.class); | ||
project.getPluginManager().apply(LicensingPlugin.class); | |||
project.getPluginManager().apply(SnykDependencyMonitoringGradlePlugin.class); | project.getPluginManager().apply(SnykDependencyMonitoringGradlePlugin.class); | ||
project.getPluginManager().apply(ClusterFeaturesMetadataPlugin.class); | project.getPluginManager().apply(ClusterFeaturesMetadataPlugin.class); | ||
InternalPrecommitTasks.create(project, true); | InternalPrecommitTasks.create(project, true); | ||
|
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.
nmcp plugin does not support java 11, so we can bump