Skip to content

Apache Lucene open-source search software

LUCENE-10304: a workaround for intellij's problem with runtime scopes on dependencies.

Dawid Weiss458c0486c005
diff --git a/build.gradle b/build.gradle
index f8d856a7762..30b31c868e3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -110,6 +110,10 @@ apply from: file('buildSrc/scriptDepVersions.gradle')
apply from: file('gradle/generation/local-settings.gradle')
+// IDE support, settings and specials.
+apply from: file('gradle/ide/intellij-idea.gradle')
+apply from: file('gradle/ide/eclipse.gradle')
+
// Set up defaults and configure aspects for certain modules or functionality
// (java, tests)
apply from: file('gradle/java/folder-layout.gradle')
@@ -124,10 +128,6 @@ apply from: file('gradle/java/modules.gradle')
// Maven artifact publishing.
apply from: file('gradle/maven/publications.gradle')
-// IDE support, settings and specials.
-apply from: file('gradle/ide/intellij-idea.gradle')
-apply from: file('gradle/ide/eclipse.gradle')
-
// Validation tasks
apply from: file('gradle/validation/measure-task-times.gradle')
apply from: file('gradle/validation/error-prone.gradle')
diff --git a/gradle/ide/intellij-idea.gradle b/gradle/ide/intellij-idea.gradle
index 1d5b8d21bd5..589aaec3562 100644
--- a/gradle/ide/intellij-idea.gradle
+++ b/gradle/ide/intellij-idea.gradle
@@ -16,7 +16,7 @@
*/
// Try to detect IntelliJ model loader ("reimport") early.
-def isIdea = System.getProperty("idea.active") != null ||
+rootProject.ext.isIdea = System.getProperty("idea.active") != null ||
gradle.startParameter.taskNames.contains('idea') ||
gradle.startParameter.taskNames.contains('cleanIdea')
diff --git a/gradle/java/modules.gradle b/gradle/java/modules.gradle
index ae232660079..db6a0f922e4 100644
--- a/gradle/java/modules.gradle
+++ b/gradle/java/modules.gradle
@@ -134,14 +134,18 @@ allprojects {
return extraArgs
})
- // Modify the default classpath by removing anything already placed on module path.
- // This could be done in a fancier way but a set difference is just fine for us here. Use a lazy
- // provider to delay computation of the actual path.
- task.classpath = files({ ->
- def trimmedClasspath = sourceSet.compileClasspath - compileModulePathConfiguration
- task.logger.info("Class path for ${task.path}:\n " + trimmedClasspath.files.sort().join("\n "))
- return trimmedClasspath
- })
+ // LUCENE-10304: if we modify the classpath here, IntelliJ no longer sees the dependencies as compile-time
+ // dependencies, don't know why.
+ if (!rootProject.ext.isIdea) {
+ // Modify the default classpath by removing anything already placed on module path.
+ // This could be done in a fancier way but a set difference is just fine for us here. Use a lazy
+ // provider to delay computation of the actual path.
+ task.classpath = files({ ->
+ def trimmedClasspath = sourceSet.compileClasspath - compileModulePathConfiguration
+ task.logger.info("Class path for ${task.path}:\n " + trimmedClasspath.files.sort().join("\n "))
+ return trimmedClasspath
+ })
+ }
})
}