tbroyer / gwt-maven-archetypes

Apache License 2.0
152 stars 39 forks source link

Add client/shared/server in package name #40

Closed freddyboucher closed 8 years ago

freddyboucher commented 8 years ago

Hi @tbroyer I'm refactoring my app to use your maven plugin but I'd like to keep client/shared and server in my package name (in addition of having them in a different maven module) instead of using the same package name for all.

But when I do it and execute mvn gwt:codeserver -pl webapp-client -am, I get:

[INFO] Super Dev Mode starting up
[INFO]    workDir: /Users/fboucher/Programming/workspace/webapp/target/gwt/codeserver
[INFO]    Loading Java files in com.test.client.App.
[INFO]    Tracing compile failure path for type 'com.test.client.App'
[INFO]       [ERROR] Errors in 'file:/Users/fboucher/Programming/workspace/webapp/webapp-client/src/main/java/com/test/client/App.java'
[INFO]          [ERROR] Line 39: No source code is available for type com.test.shared.GreetingServiceAsync; did you forget to inherit a required module?
[INFO]          [ERROR] Line 127: No source code is available for type com.test.shared.GreetingResponse; did you forget to inherit a required module?
[INFO]          [ERROR] Line 40: No source code is available for type com.test.shared.GreetingService; did you forget to inherit a required module?
[INFO]          [ERROR] Line 117: No source code is available for type com.test.shared.FieldVerifier; did you forget to inherit a required module?
[INFO]    Finding entry point classes
[INFO]       Tracing compile failure path for type 'com.test.client.App'
[INFO]          [ERROR] Errors in 'file:/Users/fboucher/Programming/workspace/webapp/webapp-client/src/main/java/com/test/client/App.java'
[INFO]             [ERROR] Line 39: No source code is available for type com.test.shared.GreetingServiceAsync; did you forget to inherit a required module?
[INFO]             [ERROR] Line 127: No source code is available for type com.test.shared.GreetingResponse; did you forget to inherit a required module?
[INFO]             [ERROR] Line 40: No source code is available for type com.test.shared.GreetingService; did you forget to inherit a required module?
[INFO]             [ERROR] Line 117: No source code is available for type com.test.shared.FieldVerifier; did you forget to inherit a required module?
[INFO]       [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] webapp ............................................. FAILURE [ 17.948 s]
[INFO] webapp-shared ...................................... SKIPPED
[INFO] webapp-client ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.772 s
[INFO] Finished at: 2016-03-06T21:19:59+11:00
[INFO] Final Memory: 27M/250M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:codeserver (default-cli) on project webapp: GWT exited with status 1 -> [Help 1]

I setup a small Github project to show you what I did: https://github.com/freddyboucher/webapp/commit/f5ead4458026f6349f18a9692bdf13718c64e375

How can I achieve that? Thanks

kaefert commented 8 years ago

I think you'll need to add the packages that contain client side code (so shared & client) to the gwt module definition here: https://github.com/freddyboucher/webapp/blob/master/webapp-client/src/main/module.gwt.xml

so replace <source path="" /> with <source path="client" /> and <source path="shared" />

tbroyer commented 8 years ago

The problem is that you have your module in com.test.client (with <source path=""/>) so com.test.shared is not in the GWT source path. To follow GWT's general conventions, you'd put your module in com.test (i.e. <moduleName>com.test.App</moduleName>). You shouldn't have to exclude com.test.server from GWT's source path, as it shouldn't be present in the classpath, but you may want to change the <source path="" /> to:

<source path="client" />
<source path="shared" />

(or just remove the <source path="" />, and the gwt:generate-module mojo will automatically generate those 2 lines along with a <super-source path="super" />).

So @kaefert is not wrong, but that wouldn't change anything alone, as the root of the problem is that you changed <moduleName>.

diff --git a/webapp-client/pom.xml b/webapp-client/pom.xml
index 69e23fd..246d403 100644
--- a/webapp-client/pom.xml
+++ b/webapp-client/pom.xml
@@ -43,7 +43,7 @@
         <groupId>net.ltgt.gwt.maven</groupId>
         <artifactId>gwt-maven-plugin</artifactId>
         <configuration>
-          <moduleName>com.test.client.App</moduleName>
+          <moduleName>com.test.App</moduleName>
           <moduleShortName>webapp</moduleShortName>
         </configuration>
       </plugin>
diff --git a/webapp-client/src/main/module.gwt.xml b/webapp-client/src/main/module.gwt.xml
index 9bb19be..4253e11 100644
--- a/webapp-client/src/main/module.gwt.xml
+++ b/webapp-client/src/main/module.gwt.xml
@@ -3,7 +3,8 @@
   <inherits name="com.google.gwt.user.User" />
   <inherits name="com.google.gwt.user.theme.clean.Clean" />

-  <source path="" />
+  <source path="client" />
+  <source path="shared" />

   <entry-point class="com.test.client.App" />
freddyboucher commented 8 years ago

You were right, I just moved the EntryPoint under com.test https://github.com/freddyboucher/webapp/commit/3ff99f3d0ab57ead3ef984b745ad045f3a5c08ee Everything works fine! Thanks @kaefert @tbroyer

tbroyer commented 8 years ago

No need to move the EntryPoint; only the module needed to move (either that or create another module in com.test.shared with <source path="" /> that the module under com.test.client <inherits/>)

freddyboucher commented 8 years ago

@tbroyer Perfect it works with my EntryPoint under /client package as you said! https://github.com/freddyboucher/webapp/commit/5adf0748b3e09fac4d9b7e6064966f3e57f4903f

PS: I'm going to open another issue because mvn jetty:start -Denv=dev and it's probably not related with this one. Thanks