Skip to content

Commit

Permalink
Isolate example plugins projects from main Elasticsearch build (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira authored Sep 22, 2021
1 parent a2373c3 commit 979f297
Show file tree
Hide file tree
Showing 24 changed files with 1,162 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Project;
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
import org.gradle.api.attributes.Attribute;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.tasks.AbstractCopyTask;
import org.gradle.api.tasks.Sync;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class InternalDistributionArchiveSetupPlugin implements InternalPlugin {

public static final String DEFAULT_CONFIGURATION_NAME = "default";
public static final String EXTRACTED_CONFIGURATION_NAME = "extracted";
public static final String COMPOSITE_CONFIGURATION_NAME = "composite";
private NamedDomainObjectContainer<DistributionArchive> container;

@Override
Expand Down Expand Up @@ -75,6 +77,12 @@ private void registerAndConfigureDistributionArchivesExtension(Project project)
extractedConfiguration.setCanBeResolved(false);
extractedConfiguration.getAttributes().attribute(ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE);
sub.getArtifacts().add(EXTRACTED_CONFIGURATION_NAME, distributionArchive.getExpandedDistTask());
// The "composite" configuration is specifically used for resolving transformed artifacts in an included build
var compositeConfiguration = sub.getConfigurations().create(COMPOSITE_CONFIGURATION_NAME);
compositeConfiguration.setCanBeResolved(false);
compositeConfiguration.getAttributes().attribute(ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE);
compositeConfiguration.getAttributes().attribute(Attribute.of("composite", Boolean.class), true);
sub.getArtifacts().add(COMPOSITE_CONFIGURATION_NAME, distributionArchive.getArchiveTask());
sub.getTasks().register("extractedAssemble", task ->
// We keep extracted configuration resolvable false to keep
// resolveAllDependencies simple so we rely only on its build dependencies here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@
import org.elasticsearch.gradle.ElasticsearchDistribution;
import org.elasticsearch.gradle.ElasticsearchDistribution.Platform;
import org.elasticsearch.gradle.ElasticsearchDistributionType;
import org.elasticsearch.gradle.internal.Jdk;
import org.elasticsearch.gradle.internal.JdkDownloadPlugin;
import org.elasticsearch.gradle.Version;
import org.elasticsearch.gradle.VersionProperties;
import org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin;
import org.elasticsearch.gradle.internal.Jdk;
import org.elasticsearch.gradle.internal.JdkDownloadPlugin;
import org.elasticsearch.gradle.internal.conventions.GUtils;
import org.elasticsearch.gradle.internal.conventions.util.Util;
import org.elasticsearch.gradle.internal.docker.DockerSupportPlugin;
import org.elasticsearch.gradle.internal.docker.DockerSupportService;
import org.elasticsearch.gradle.internal.info.BuildParams;
import org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin;
import org.elasticsearch.gradle.test.SystemPropertyCommandLineArgumentProvider;
import org.elasticsearch.gradle.util.GradleUtils;
import org.elasticsearch.gradle.internal.conventions.util.Util;
import org.elasticsearch.gradle.internal.vagrant.VagrantBasePlugin;
import org.elasticsearch.gradle.internal.vagrant.VagrantExtension;
import org.elasticsearch.gradle.internal.conventions.GUtils;
import org.elasticsearch.gradle.test.SystemPropertyCommandLineArgumentProvider;
import org.elasticsearch.gradle.util.GradleUtils;
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
import org.gradle.api.internal.artifacts.ArtifactAttributes;
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.provider.Provider;
import org.gradle.api.specs.Specs;
Expand Down Expand Up @@ -310,9 +312,9 @@ private static Object convertPath(

private static Configuration configureExamplePlugin(Project project) {
Configuration examplePlugin = project.getConfigurations().create(EXAMPLE_PLUGIN_CONFIGURATION);
examplePlugin.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.ZIP_TYPE);
DependencyHandler deps = project.getDependencies();
Map<String, String> examplePluginProject = Map.of("path", ":example-plugins:custom-settings", "configuration", "zip");
deps.add(EXAMPLE_PLUGIN_CONFIGURATION, deps.project(examplePluginProject));
deps.add(EXAMPLE_PLUGIN_CONFIGURATION, deps.create("org.elasticsearch.examples:custom-settings:1.0.0-SNAPSHOT"));
return examplePlugin;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.Transformer;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.type.ArtifactTypeDefinition;
import org.gradle.api.file.RegularFile;
import org.gradle.api.internal.artifacts.ArtifactAttributes;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
Expand Down Expand Up @@ -238,7 +241,8 @@ public Object doCall() {
project.getTasks().named(BasePlugin.ASSEMBLE_TASK_NAME).configure(task -> task.dependsOn(bundle));

// also make the zip available as a configuration (used when depending on this project)
project.getConfigurations().create("zip");
Configuration configuration = project.getConfigurations().create("zip");
configuration.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.ZIP_TYPE);
project.getArtifacts().add("zip", bundle);

return bundle;
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ if (project.gradle.startParameter.taskNames.find { it.startsWith("checkPart") }
bwc_tests_enabled = false
}

allprojects {
subprojects {
// common maven publishing configuration
group = 'org.elasticsearch'
version = VersionProperties.elasticsearch
description = "Elasticsearch subproject ${project.path}"
}

allprojects {
// We disable this plugin for now till we shaked out the issues we see
// e.g. see https://github.com/elastic/elasticsearch/issues/72169
// apply plugin:'elasticsearch.internal-test-rerun'
Expand Down Expand Up @@ -367,6 +369,7 @@ tasks.register("branchConsistency") {
}

tasks.named("wrapper").configure {
dependsOn gradle.includedBuild('example-plugins').task(':wrapper')
distributionType = 'ALL'
doLast {
final DistributionLocator locator = new DistributionLocator()
Expand Down Expand Up @@ -407,11 +410,13 @@ gradle.projectsEvaluated {
tasks.named("precommit") {
dependsOn gradle.includedBuild('build-tools').task(':precommit')
dependsOn gradle.includedBuild('build-tools-internal').task(':precommit')
dependsOn gradle.includedBuild('example-plugins').task(':precommit')
}

tasks.named("checkPart1").configure {
dependsOn gradle.includedBuild('build-tools').task(':check')
dependsOn gradle.includedBuild('build-tools-internal').task(':check')
dependsOn gradle.includedBuild('example-plugins').task(':check')
}

tasks.named("assemble").configure {
Expand Down
8 changes: 8 additions & 0 deletions plugins/examples/NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Elasticsearch
Copyright 2009-2021 Elasticsearch

This product includes software developed by The Apache Software
Foundation (http://www.apache.org/).

This product includes software developed by
Joda.org (http://www.joda.org/).
Loading

0 comments on commit 979f297

Please sign in to comment.