dweiss commented on a change in pull request #470:
URL: https://github.com/apache/lucene/pull/470#discussion_r765741925



##########
File path: gradle/java/modules.gradle
##########
@@ -199,6 +200,67 @@ allprojects {
       }
     }
 
+    // Configure the test task.
+    tasks.matching { it.name == "test" }.all { Test task ->
+      Configuration modulePath = 
task.project.configurations.maybeCreate("moduleTestCompilePath")
+      task.dependsOn modulePath
+
+      SourceSet sourceSet = task.project.sourceSets.test
+
+      Predicate<SourceSet> hasModuleDescriptor = { SourceSet ss ->
+        ss.allJava.srcDirs.stream()
+            .map(dir -> new File(dir, "module-info.java"))
+            .anyMatch(file -> file.exists())
+      }
+
+      // Add modular dependencies and their transitive dependencies to module 
path.
+      task.jvmArgumentProviders.add(new CommandLineArgumentProvider() {
+        @Override
+        Iterable<String> asArguments() {
+          def extraArgs = []
+
+          // Determine whether the source set classes themselves should be 
appended to classpath
+          // or module path.
+          boolean sourceSetIsAModule = hasModuleDescriptor.test(sourceSet)
+
+          if (!modulePath.isEmpty() || sourceSetIsAModule) {
+            if (sourceSetIsAModule) {
+              // Add source set outputs to module path.
+              extraArgs += ["--module-path", (modulePath + 
sourceSet.output.classesDirs).files.join(File.pathSeparator) ]
+              // TODO: we should only initially add the sourceset's module? 
Everything else would be resolved via the

Review comment:
       @ChrisHegarty Can you take a look at this? What do you think? I believe 
we can just add the tested project's module here, without pulling everything 
in? I don't know if we can retrieve the name of the module in any other way 
than by parsing module-info.class (using java APIs); the only problem here is 
when gradle's JVM is older than the compilation/ test JVM - then things will 
break.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to