When adding a project dependency to an existing project, it is possible to set the Without test code attribute, so that paths marked with Contains test sources are not added to the classpath.
This attribute is persisted as without_test_code in the .classpath file.
The incremental Java compiler already takes this attribute into account, so that marked test classes from the project dependency are not accessible. But when launching a JUnit test the resolved classpath contains the output locations for the unwanted test paths. Here is an example (example.tar.gz):
Classpath of projectA
path="main", output="bin/main"
path="test", output="bin/test", test=true
Classpath of projectB
path="test", output="bin", test=true
path="/projectA", without_test_code=true
When launching a test from projectB, classes from /projectA/test are accessible via reflection - but they should'nt. (The reflective access is necessary here, because in the Java editor the compiler already cannot see these classes.) It is possible to exclude all test code in the launcher (see tab Dependencies) - but this a different thing.
To solve this problem, the two JavaRuntime.resolveRuntimeClasspathEntry(...) methods (one for launch configurations, another for projects) should evaluate the attribute without_test_code when resolving project dependencies.
When adding a project dependency to an existing project, it is possible to set the Without test code attribute, so that paths marked with Contains test sources are not added to the classpath.
This attribute is persisted as
without_test_code
in the.classpath
file.The incremental Java compiler already takes this attribute into account, so that marked test classes from the project dependency are not accessible. But when launching a JUnit test the resolved classpath contains the output locations for the unwanted test paths. Here is an example (example.tar.gz):
When launching a test from
projectB
, classes from/projectA/test
are accessible via reflection - but they should'nt. (The reflective access is necessary here, because in the Java editor the compiler already cannot see these classes.) It is possible to exclude all test code in the launcher (see tab Dependencies) - but this a different thing.To solve this problem, the two
JavaRuntime.resolveRuntimeClasspathEntry(...)
methods (one for launch configurations, another for projects) should evaluate the attributewithout_test_code
when resolving project dependencies.