-
Notifications
You must be signed in to change notification settings - Fork 172
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
Test classes and resources of dependency are in classpath even with without_test_code=true #1270
Comments
Your
In Buildship, references to other projects and external dependencies are handled with the Gradle Classpath Container which is automatically added to the
There should be no direct entry for The actual entries of the classpath container can be inspected in the Package or Project Explorer under the folder Project and External Dependencies: With theses steps you can ensure that the projects will be correctly imported:
|
Hello, However, it does not when using For the last option, I've had this understanding because I had to tweak some classpath attributes to make other things work, such as |
After invoking
That looks correct and also importing these as normal projects (and not via Buildship) shows the expected behavior, e.g. the properties for projectB:
Could you provide a minimal reproducible example for your concrete case? |
Thanks for checking this out. The best way to reproduce the issue would be to clone https://github.com/sebkur/test-gradle-eclipse You can tweak the gradle version in Then you run But then, if you try to run test
Because it'll find both If you look at the generated command line, you can see the test classpath of |
Thank you for the detailed explanations. The problem is independent of Gradle or Buildship and has to be solved in JDT Debug. I have created Issue #327 and provided pull request #328. I hope it will be accepted. Since Buildship already handles the attribute Without test code correctly, this issue should be closed. |
Thanks again for checking this out and for dispatching it (and fixing it!) to the correct project! |
@Tiller The pull request #328 has been integrated and will be part of the upcoming Eclipse 2024-03 (release date 2024-03-13). Integration builds with this fix are already available. |
Expected Behavior
Given the following project structure:
With projectB containing:
MyClass
andmyResource.txt
should not be in the test classpath ofprojectB
.MyOtherClass
shouldn't be able to accessMyClass
ormyResource.txt
Current Behavior
projectA/bin/test
is in the classpath ofprojectB
when running tests contained inMyOtherClass
.Eclipse's generated command line is :
even though .classpath contains:
Context
I'm having issues with some tests in projectB that does some reflection / classpath scanning that ends-up with test classes of projectA
Steps to Reproduce
User sebkur opened a strictly identical issue years ago (#1009) and provided a perfectly good example of the issue :
https://github.com/sebkur/test-gradle-eclipse
In eclipse, test
TestResources.test()
fails because it sees a resource that is in the test classpath of a dependency.Your Environment
OS: Ubuntu 22.04
Gradle: tested with 7.4.2, 7.6.2 and 8.2.1
Eclipse: tested with 2023-03 and 2023-09, with buildship 3.1.7 (and the version that was shipped with 2023-03)
The text was updated successfully, but these errors were encountered: