Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/elastic/elasticsearch into …
Browse files Browse the repository at this point in the history
…112704_fix
  • Loading branch information
astefan committed Sep 20, 2024
2 parents 4facf83 + 7c65ad5 commit b55b2eb
Show file tree
Hide file tree
Showing 50 changed files with 421 additions and 1,465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.compile.CompileOptions;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.api.tasks.testing.Test;
import org.gradle.external.javadoc.CoreJavadocOptions;
import org.gradle.jvm.tasks.Jar;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.jvm.toolchain.JavaToolchainService;
Expand Down Expand Up @@ -73,8 +75,10 @@ public void apply(Project project) {
List<Integer> mainVersions = findSourceVersions(project);
List<String> mainSourceSets = new ArrayList<>();
mainSourceSets.add(SourceSet.MAIN_SOURCE_SET_NAME);
configurePreviewFeatures(project, javaExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME), 21);
List<String> testSourceSets = new ArrayList<>(mainSourceSets);
testSourceSets.add(SourceSet.TEST_SOURCE_SET_NAME);
configurePreviewFeatures(project, javaExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME), 21);
for (int javaVersion : mainVersions) {
String mainSourceSetName = SourceSet.MAIN_SOURCE_SET_NAME + javaVersion;
SourceSet mainSourceSet = addSourceSet(project, javaExtension, mainSourceSetName, mainSourceSets, javaVersion);
Expand Down Expand Up @@ -124,11 +128,8 @@ private SourceSet addSourceSet(
compileTask.setSourceCompatibility(Integer.toString(javaVersion));
CompileOptions compileOptions = compileTask.getOptions();
compileOptions.getRelease().set(javaVersion);
compileOptions.getCompilerArgs().add("--enable-preview");
compileOptions.getCompilerArgs().add("-Xlint:-preview");

compileTask.doLast(t -> { stripPreviewFromFiles(compileTask.getDestinationDirectory().getAsFile().get().toPath()); });
});
configurePreviewFeatures(project, sourceSet, javaVersion);

// Since we configure MRJAR sourcesets to allow preview apis, class signatures for those
// apis are not known by forbidden apis, so we must ignore all missing classes. We could, in theory,
Expand All @@ -142,6 +143,21 @@ private SourceSet addSourceSet(
return sourceSet;
}

private void configurePreviewFeatures(Project project, SourceSet sourceSet, int javaVersion) {
project.getTasks().withType(JavaCompile.class).named(sourceSet.getCompileJavaTaskName()).configure(compileTask -> {
CompileOptions compileOptions = compileTask.getOptions();
compileOptions.getCompilerArgs().add("--enable-preview");
compileOptions.getCompilerArgs().add("-Xlint:-preview");

compileTask.doLast(t -> { stripPreviewFromFiles(compileTask.getDestinationDirectory().getAsFile().get().toPath()); });
});
project.getTasks().withType(Javadoc.class).named(name -> name.equals(sourceSet.getJavadocTaskName())).configureEach(javadocTask -> {
CoreJavadocOptions options = (CoreJavadocOptions) javadocTask.getOptions();
options.addBooleanOption("-enable-preview", true);
options.addStringOption("-release", String.valueOf(javaVersion));
});
}

private void configureSourceSetInJar(Project project, SourceSet sourceSet, int javaVersion) {
var jarTask = project.getTasks().withType(Jar.class).named(JavaPlugin.JAR_TASK_NAME);
jarTask.configure(task -> task.into("META-INF/versions/" + javaVersion, copySpec -> copySpec.from(sourceSet.getOutput())));
Expand Down
5 changes: 0 additions & 5 deletions libs/native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import org.elasticsearch.gradle.internal.precommit.CheckForbiddenApisTask
apply plugin: 'elasticsearch.publish'
apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.mrjar'
apply plugin: 'elasticsearch.embedded-providers'

embeddedProviders {
impl 'native-access-jna', project(':libs:elasticsearch-native:jna')
}

dependencies {
api project(':libs:elasticsearch-core')
Expand Down
31 changes: 0 additions & 31 deletions libs/native/jna/build.gradle

This file was deleted.

177 changes: 0 additions & 177 deletions libs/native/jna/licences/jna-LICENSE.txt

This file was deleted.

1 change: 0 additions & 1 deletion libs/native/jna/licences/jna-NOTICE.txt

This file was deleted.

Loading

0 comments on commit b55b2eb

Please sign in to comment.