New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LUCENE-10328: Module path for compiling and running tests is wrong #571
Conversation
… test fixtures plugin provides another layer of complexity to managing dependencies - the gain is so minimal here that I removed it.
…rcular dependncies can be figured out.
…broken with modules/" This reverts commit 7743921.
…headFilter so that it's not picked up as a test.
… is a sad case of difference in how javac and ecj consider classes on module path vs. classpath
There is now a warning by ECJ, but does not fail build. I will fix this in main, sorry. |
Sorry, github was too slow and I accidentally pressed button twice. |
Fixed warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not fully understand all changes, but I hope that's fine. Everyday something new with modules.
At moment I have a few questions:
- When are tests run as separate module (integration tests)? Is this decided based on the gradle name or the existence of a module-info.java inside the test's source dir?
- When do we use module patching (I still see sometimes patching, but haven't figured out when it is done)? Do we run tests always inside the main sourcesets module (patching) or do we just run those in classpath (when the tests have no module-info.java?)
If you have some time, we can do a Zoom meeting to go through this patch. I am a bit lost.
I trust you so maybe commit it and I will se how it behaves.
Please take a look at this comment/ chart, Uwe. How tests are run depends on the combination of whether source and test source sets are modules. We do not have module patching. I don't think it's possible to configure gradle internal infrastructure and plugins to reasonably use it. |
OK thanks for the picture. Much more information. I was hoping it is like that. That module patching does not work was known to me, I just stumbled on some support methods for it and I did not understand when they are used. I am perfectly fine when we run our tests for a class in classpath mode, although the main sourceset is modular. Technically this won't change the test results, as UNIT tests should only check internal assertions. Of course in reality it is more complicated. What I understood and which is missing in the image: The depenendecies are always modular, so lucene.core is put on module-path, even so we are running tests in classpath mode. This is waht this PR mainly changes, correct? reviously it was not fully working unless you explicitely declared it. What we should now do (after this is merged):
Uwe |
I think you have to solve the conflicts caused by the change for running "gradlew beast". I leave that up to you. Maybe it works better after this branch is merged. |
@@ -57,7 +57,7 @@ allprojects { | |||
outputDir = project.javadoc.destinationDir | |||
} | |||
|
|||
if (project.path == ':lucene:luke' || project.path.endsWith(".tests")) { | |||
if (project.path == ':lucene:luke' || !(project in rootProject.ext.mavenProjects)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this mavenProjects
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it is inverse. All projects that will land in Maven central. Yeah thats a better check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the way theres also the better operator project !in rootProject.ext.mavenProjects
I used is elsewhere already.
gradle/java/modules.gradle
Outdated
// Configure (tasks.test, sourceSets.test) | ||
tasks.matching { it.name == "test" }.all { Test task -> | ||
// Lazily configure (tasks.test, sourceSets.test) | ||
tasks.matching { it.name ==~ /test(_[0-9]+)?/ }.all { Test task -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that change, so you can merge by using "use mine".
Why can't we lazily find all test tasks using tasks.matching { it instance of Test }.all
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shoudl also check that instrumentation with Emma works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that change, so you can merge by using "use mine".
Why can't we lazily find all test tasks using
tasks.matching { it instance of Test }.all
?
lucene.core (and any other dependency placed in modular configurations) is correctly inserted on module-path if this reference is from "outside" the project itself. In other words, the tests within lucene.core run with main source set classes on classpath (otherwise you'd have split package errors) but anywhere else where you reference lucene.core, it will be placed on module-path. That debug flag (-Pbuild.debug.paths=true) shows verbosely how classpath and module path is configured for each task. |
No description provided.