forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into esql/nested-aggs
- Loading branch information
Showing
604 changed files
with
19,452 additions
and
5,187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...s-internal/src/main/java/org/elasticsearch/gradle/internal/EmbeddedProviderExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.artifacts.Configuration; | ||
import org.gradle.api.file.Directory; | ||
import org.gradle.api.provider.Provider; | ||
import org.gradle.api.tasks.SourceSet; | ||
import org.gradle.api.tasks.Sync; | ||
|
||
import static org.elasticsearch.gradle.internal.conventions.GUtils.capitalize; | ||
import static org.elasticsearch.gradle.util.GradleUtils.getJavaSourceSets; | ||
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE; | ||
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.DIRECTORY_TYPE; | ||
|
||
public class EmbeddedProviderExtension { | ||
|
||
private final Project project; | ||
|
||
public EmbeddedProviderExtension(Project project) { | ||
this.project = project; | ||
} | ||
|
||
void impl(String implName, Project implProject) { | ||
String projectName = implProject.getName(); | ||
String capitalName = capitalize(projectName); | ||
|
||
Configuration implConfig = project.getConfigurations().detachedConfiguration(project.getDependencies().create(implProject)); | ||
implConfig.attributes(attrs -> { | ||
attrs.attribute(ARTIFACT_TYPE_ATTRIBUTE, DIRECTORY_TYPE); | ||
attrs.attribute(EmbeddedProviderPlugin.IMPL_ATTR, true); | ||
}); | ||
|
||
String manifestTaskName = "generate" + capitalName + "ProviderManifest"; | ||
Provider<Directory> generatedResourcesDir = project.getLayout().getBuildDirectory().dir("generated-resources"); | ||
var generateProviderManifest = project.getTasks().register(manifestTaskName, GenerateProviderManifest.class); | ||
generateProviderManifest.configure(t -> { | ||
t.getManifestFile().set(generatedResourcesDir.map(d -> d.file("LISTING.TXT"))); | ||
t.getProviderImplClasspath().from(implConfig); | ||
}); | ||
|
||
String implTaskName = "generate" + capitalName + "ProviderImpl"; | ||
var generateProviderImpl = project.getTasks().register(implTaskName, Sync.class); | ||
generateProviderImpl.configure(t -> { | ||
t.into(generatedResourcesDir); | ||
t.into("IMPL-JARS/" + implName, spec -> { | ||
spec.from(implConfig); | ||
spec.from(generateProviderManifest); | ||
}); | ||
}); | ||
|
||
var mainSourceSet = getJavaSourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME); | ||
mainSourceSet.getOutput().dir(generateProviderImpl); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ools-internal/src/main/java/org/elasticsearch/gradle/internal/EmbeddedProviderPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal; | ||
|
||
import org.elasticsearch.gradle.transform.UnzipTransform; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.attributes.Attribute; | ||
|
||
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE; | ||
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.DIRECTORY_TYPE; | ||
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.JAR_TYPE; | ||
|
||
public class EmbeddedProviderPlugin implements Plugin<Project> { | ||
static final Attribute<Boolean> IMPL_ATTR = Attribute.of("is.impl", Boolean.class); | ||
|
||
@Override | ||
public void apply(Project project) { | ||
|
||
project.getDependencies().registerTransform(UnzipTransform.class, transformSpec -> { | ||
transformSpec.getFrom().attribute(ARTIFACT_TYPE_ATTRIBUTE, JAR_TYPE).attribute(IMPL_ATTR, true); | ||
transformSpec.getTo().attribute(ARTIFACT_TYPE_ATTRIBUTE, DIRECTORY_TYPE).attribute(IMPL_ATTR, true); | ||
transformSpec.parameters(parameters -> parameters.getIncludeArtifactName().set(true)); | ||
}); | ||
|
||
project.getExtensions().create("embeddedProviders", EmbeddedProviderExtension.class, project); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.