Skip to content

Apache Lucene open-source search software

Make intellij think vector module is imported for mrjar/java25 module. (#15583)

Dawid Weissee4522fecee5
diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/mrjar/LuceneJavaCoreMrjarPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/mrjar/LuceneJavaCoreMrjarPlugin.java
index 378edc7e557..03c088d84e6 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/mrjar/LuceneJavaCoreMrjarPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/mrjar/LuceneJavaCoreMrjarPlugin.java
@@ -107,14 +107,24 @@ public class LuceneJavaCoreMrjarPlugin extends LuceneGradlePlugin {
compilerArgs.remove("-Xlint:options");
compilerArgs.add("-Xlint:-options");
- compilerArgs.addAll(
- List.of(
- "--add-exports",
- "java.base/java.lang.foreign=ALL-UNNAMED",
- // for compilation, we patch the incubator packages into java.base, this has
- // no effect on resulting class files:
- "--add-exports",
- "java.base/jdk.incubator.vector=ALL-UNNAMED"));
+ if (getLuceneBuildGlobals(project).getIntellijIdea().get().isIdeaSync()) {
+ // Let's make it simpler for intellij so that it doesn't complain
+ // about inaccessible incubator module. We enable this only for
+ // "syncing" IDE settings, not for actual compilation done from within
+ // the IDE.
+ compilerArgs.addAll(List.of("--add-modules", "jdk.incubator.vector"));
+ compilerArgs.remove("-Xlint:incubating");
+ compilerArgs.remove("-Xlint:-incubating");
+ } else {
+ compilerArgs.addAll(
+ List.of(
+ "--add-exports",
+ "java.base/java.lang.foreign=ALL-UNNAMED",
+ // for compilation, we patch the incubator packages into java.base, this
+ // has no effect on resulting class files:
+ "--add-exports",
+ "java.base/jdk.incubator.vector=ALL-UNNAMED"));
+ }
var argsProvider = project.getObjects().newInstance(CompilerArgsProvider.class);
argsProvider.getApiJarFile().set(apijar);
diff --git a/lucene/luke/build.gradle b/lucene/luke/build.gradle
index b90b8eeda7b..ee98d136cf2 100644
--- a/lucene/luke/build.gradle
+++ b/lucene/luke/build.gradle
@@ -61,6 +61,7 @@ tasks.named("compileJava").configure {
}
// Process UTF8 property files to unicode escapes.
+
tasks.withType(ProcessResources).configureEach { task ->
task.filesMatching("**/messages*.properties", {
filteringCharset = 'UTF-8'