Closed bwehrle closed 2 years ago
Thanks @bwehrle We don't see that failure at all. Are you using Gradle?
No, this is using normal IntelliJ with maven. I had not had this problem before, but have not been able to compile xoom-actors in IntelliJ without manually fixing the file to code to use "forTest" while running my tests. Regardless, even if it works in Maven, there is an undesirable consequence of shipping test code with production jars.
When I do all of my building using Maven inside IntelliJ it works fine. But when I try to run/debug an individual test, the build fails. In order to reproduct, you need to try to run a specific test or test class.
If I delegate all the build to Maven the problem goes away. But the debugger does not work for me in IntelliJ when trying to debug maven executions, so that is not a work around.
@bwehrle I found the issue. Some of our pom.xml
files across the platform are missing the plugin and test-compile
configuration that prevents this issue:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
We should soon have fixes in xoom-*-1.9.4-SNAPSHOT
.
@bwehrle I was wrong in my previous diagnosis. The way this has been addressed is as follows:
World
is started it discovers whether it is running under main
or test
. The current approach is quite simplistic but I think it is reliable.
World
discovers that it is under test, it prepares the ActorProxy
to use ProxyGenerator.forTest(...)
rather than ProxyGenerator.forMain(...)
.forMain()
to fail before attempting forTest()
. I recall that this worked much earlier so there must have been some changes that broke it. Still this new approach is reliable.ActorProxy
is set up for test, it will always generate under target/generated-test-sources
.xoom-actors
and when the World discovers that the runtime is under test, 100% of proxies are created under target/generated-test-sources
.You can review the code here: https://github.com/vlingo/xoom-actors/compare/7e51eea466e1...0711bab912da
Please test with your environment. Another developer on our team will test inside IntelliJ.
Hi @VaughnVernon - thanks for fixing this. I was surprised to see that there is no other way to determine that something is running under test or main. However, this does indeed fix the problem.
I confirmed that under Maven there is no such problem and in no case does test code get shipped with the production jar even without this fix. So we can close this one.
Thanks for confirming @bwehrle!
When using IntelliJ the xoom-actors project does not compile. The proxies generated for test classes are put into the generated-soures directory (for main modules). The compilation of this directory fails because these proxies are referencing types in the test path that are not in the non-test compile path.
It turns out that every proxy is generated and put inside the main generated resources. This is not technically correct- even if it works for maven- as it implies shipping production jars with non-production interfaces/implementations.
See io/vlingo/xoom/actors/ActorProxy.java:82
The solution should consider the source of the class and chose the ProxyGenerator "forMain" or "forTest" method.