Saturday, December 3, 2016

Re: About running tests in a project built via tbroyer's maven multi-module archetype



On Friday, December 2, 2016 at 8:06:23 PM UTC+1, vitrums wrote:
Is it safe to leave it like this?

Absolutely.

And actually, there's no bug in gwt:test. gwt:test (actually, GWTTestCases, whether run through gwt:test or surefire:test or whatever) simply expects the sources to be on the classpath.
What you faced was just a limitation of Maven's linear lifecycle when combined with reactor builds: because source:jar-no-fork in shared-lib was bound to the package phase, and you didn't run it (you only run the lifecycle up to the test phase, in each module) the source-jar wasn't available (and neither was the jar BTW). When Maven needs to resolve a dependency from the reactor build and no artifact has been attached to the project, it simply defaults to using target/classes (it actually depends on the packaging), so you never got your sources when running tests. By attaching the source:jar-no-fork to the process-classes phase, when the test phase is run, the source-jar is attached to the project so it can be resolved.
My take on this is that you shouldn't ever run any lifecycle phase prior to package (at least in a reactor build), and this is why I attached the source:jar-no-fork to the package phase in the gwt-maven-archetypes. Failing to run at least up to the package phase means that your artifacts aren't fully built and attached, and Maven uses heuristics to replace them, and it can fail you and cause all sorts of issues (generally breaking your build, but it could also cause false-positives).

All this discussion makes me want to write (yet another) blog post on why Maven is broken by design, and how to avoid failing into its traps (basically: use "mvn verify" instead of "mvn install" as that's what you want 99% of the time, never run anything prior to the package phase in a reactor build, and use -DskipTests or -Dmaven.test.skip if you want to skip tests, or -Dtest=<pattern> to filter tests to run)

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment