Closed reinert closed 9 years ago
Did you use the dev
profile (using either -Ddev
or -Pdev
) ? It adds the shared
modules' sources to the client
modules' resources so they're available to GWT.
There might however be a class of changes that require running javac
again and relaunching DevMode / SDM.
Yeah, I was using dev profile.
The problem was related to the resources inclusion.
The only way I could get it to work was adding sources instead of resources in the compie phase.
The build-helper-maven-plugin was configured as following:
<phase>compile</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<!-- Only sources, resources are already in the classpath, by definition -->
<resource>
<directory>${basedir}/../gwtthiago-shared/src/main/java</directory>
</resource>
</resources>
</configuration>
I had to change to:
<phase>compile</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<!-- Only sources, resources are already in the classpath, by definition -->
<source>${basedir}/../gwtthiago-shared/src/main/java</source>
</sources>
</configuration>
Actually, I don't quite understand why it was configured to include the shared sources as 'resources'. Was it supposed to work?
You don't want the shared
classes to be compiled into the client
's target/classes
, this is why it was set as add-resource
. Now we could maybe use add-source
in the process-classes
phase? But what we really want is have the sources in the classpath, so add-resource
should work as advertized.
What kind of "breaking change" did you do in the shared
class? Also, with your add-source
setup, did the shared
classes imported this way end up being compiled by the maven-compiler-plugin
as part of the client
build?
Ok! Now I clearly understand!
Actually my problem wasn't in the client POM, but in shared.
It happens that I'm using gwt-maven-plugin generateAsync goal, and the sources generated in another folder wasn't being compiled!
Although in the client I was referencing the shared generated folder...
<resource>
<directory>${basedir}/../gwtthiago-shared/target/generated-sources/gwt</directory>
</resource>
... I wasn't including this folder in the shared compilation. So client's compilation couldn't find any compiled classes there, only sources! I solved by adding the generated sources folder in shared compilation with build helper plugin.
Thanks for helping me out!
Note: generateAsync
should add its output directory to the project's sources without the need for the build-helper-maven-plugin. It's possible however that the generated code wouldn't be packaged in the sources
JAR.
Actually you were right: gwt-maven-plugin purposefully doesn't add resources to the classpath, so add-source
has to be used. Currently working on the fix.
Why 'purposefully'?
When working in client, I made a breaking change on a class in shared module. Then after trying to recompile in SDM, I got compiling issues (API incompatibility).
After trying compile and package lifecycles, I realized that only by installing shared module, I could synchronize shared compiled code to client. Then I had to restart SDM again.
Is there a better way to get shared module synchronized with client when working in SDM?