-
Notifications
You must be signed in to change notification settings - Fork 911
Support running classes from specific Gradle source sets in Gradle actions #8897
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
base: master
Are you sure you want to change the base?
Conversation
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.
Thank you!
...radle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NetBeansRunSinglePlugin.java
Outdated
Show resolved
Hide resolved
java/gradle.java/src/org/netbeans/modules/gradle/java/GradleJavaTokenProvider.java
Outdated
Show resolved
Hide resolved
java/gradle.java/src/org/netbeans/modules/gradle/java/GradleJavaTokenProvider.java
Outdated
Show resolved
Hide resolved
...radle-tooling/src/main/java/org/netbeans/modules/gradle/tooling/NetBeansRunSinglePlugin.java
Outdated
Show resolved
Hide resolved
...a.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
Show resolved
Hide resolved
...a.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
Outdated
Show resolved
Hide resolved
...a.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
Outdated
Show resolved
Hide resolved
d05fc28 to
d632d1b
Compare
|
the LSP |
|
I tried running the same tests on the |
the LSP job does run when a PR is merged, it seems to work on master https://github.com/apache/netbeans/actions?query=branch%3Amaster, last success was 4h ago |
|
|
I will try to check then more on the tests. Thanks much for verifying it. |
|
I was looking at the test. The test is testing the DAP client, by running the The reason why the test fails is, I think, this: the test does not specify any There are multiple aspects to this:
|
|
@lahodaj, thank you so much for looking into it. I also believe that using |
| "file", FileUtil.toFile(testFile).getAbsolutePath(), | ||
| "classPaths", List.of("any"))) | ||
| "classPaths", List.of("any"), | ||
| "testRun", false)) |
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.
Does this change mean the behaviour of the service has changed in an incompatible way ?
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.
Earlier, the logic checked if a file wasn’t a test file by trying to find the source of the root file of that test file. If no source was found, it would assume the file was a mainSource: true. However, this approach was a bit hacky for determining whether a file is a mainClass. As a result, in some cases, files inside the test sources that were actually mainClass files were incorrectly classified as test files, causing tests to run instead of executing the mainClass.
The new approach uses sourceCP directly to check whether a file is a mainClass.
However, since indexing wasn’t run in the tests scenario , it fails to identify mainClass files correctly in the failing test scenarios.
If there are any changes required in the changed behaviour, please let me know.
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 suspect the current proposed state goes a little bit too far. Unless there's a proof the given class is a main class/has a main method, it will use the test actions to run the file. As I said, I don't know what is the state with Gradle, but for other project types, this is likely to fail, as they don't support test actions outside of the test roots.
I suspect a hybrid approach would work better: for stuff outside of test roots, use the non-test actions. For stuff in test roots, look at whether the given class has a main method.
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.
Sorry, I didn’t understand your comment at first, @lahodaj. I’ve now made the changes according to your suggestions.
7ef4048 to
653c8eb
Compare
…ebug action didn't work, fixed that
653c8eb to
7d33f32
Compare
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.
NbLaunchDelegate seems good to me now. Thanks!
When a
mainClassis defined in a source set other thanmainin a Gradle project, the NetBeans Gradle action was unable to run or debug that class. This has been fixed by introducing a new project configuration parameter,runSourceSetName, similar torunSelectedClassName.Additionally, in the LSP launch configuration, specifying a
mainClassfrom a non-mainsource set inlaunch.jsonpreviously caused it to run as if it were part of the test source set. This behavior has been corrected so that the specifiedmainClassis now executed properly instead of running tests.Before fix:
After fix:
Related issue: oracle/javavscode#353