4

I have a maven multi-module project. One of this modules (compiled as .jar) contains only domain objects, which will be used at client and server sides (I add this .jar as dependency to other my modules).

I know that GWT module, where will be used objects from shared .jar, must also have source files for successful compilation. So I tried to add to my pom.xml both:

        <resources> 
            <resource>
              <directory>src/main/java/<path></directory> 
              <includes> 
                <include>**/*.java</include> 
                <include>**/*.gwt.xml</include> 
              </includes> 
            </resource> 
        </resources>  

and

 <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>gwt-maven-plugin</artifactId>
    <versionRange>[${gwt.version}]</versionRange>
    <goals>
        <goal>resources</goal>
    </goals>
 <plugin>

But resulting .jar don't contain GWT module source (i.e gwt.xml). All sources of domain classes are added as well (at root directory of .jar), but ModuleName.gwt.xml not.

Where is problem? Thanks.

WelcomeTo
  • 19,843
  • 53
  • 170
  • 286
  • Where in the source tree is the gwt.xml file? – Anders R. Bystrup Nov 14 '12 at 15:36
  • @MyTitle: as you're using GWT+Maven and building libraries, come cast your vote as the preferred/standard layout for GWT libraries (where to put `.gwt.xml` and the like): https://groups.google.com/d/topic/google-web-toolkit/Y0dqogsT1Zw/discussion – Thomas Broyer Nov 14 '12 at 16:07

3 Answers3

2

If your .gwt.xml file is in src/main/resources/ then it won't get copied if you specify src/main/java/ as the resource path...

You should probably omit the <resource> section and let the GWT plugin include the source in the jar or at least have two sections, one for the .gwt.xml file (src/main/resources or where you put it) and one for the source code (as you have it now).

Cheers,

Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55
  • 2
    In other words: if you have a `` section, it **replaces** the default `src/main/resources`, it doesn't **add** to it (the `**/*.gwt.xml` makes me wonder though if @MyTitle's `.gwt.xml` rather is in `src/main/java`). – Thomas Broyer Nov 14 '12 at 16:05
  • My `.gwt.xml` in `ru.company.name.domain`, and my souce classes inside `ru.company.name.domain.object` package. Inside `src/main/resources` I haven't any files. And in `` section I tried also several variations of `.gwt.xml` path, e.g. `**/*.gwt.xml`, `*.gwt.xml` and also I tried full path etc (of course with a corresponding path changes in `` section). **Anyway, why using `gwt-maven-plugin` results in same error?** (In question I meant that I tried both (`` and `gwt-maven-plugin` for generating sources) separately, but not together). Thanks. – WelcomeTo Nov 14 '12 at 17:28
  • Solved using `` section (set correct path), but `gwt-maven-plugin` still doesn't work. This is strange.. – WelcomeTo Nov 15 '12 at 11:58
0

I was troubleshooting this error today so I'm just posting my fix:

Multi-module gwt project being build with the maven gwt plugin needs an entry in the pom.xml like:

  <modules>
        <module>../theothermodule</module>
  </modules>

In order to compile.

bsautner
  • 4,479
  • 1
  • 36
  • 50
0

This error have multiple explanations. Check list:

  • if you are referencing a gwt module you need to point to the *.gwt.xml file in dot notation without the file extension. E.g. com.example.ThirdParty refers to com/example/ThirdParty.gwt.xml module
  • to import the 3rd party module, add <inherits name="com.example.ThirdParty" /> to your *.gwt.xml file
  • the ThirdParty.gwt.xml should contain one or more source elements pointing to translatable code. E.g. <source path='shared' />.
  • all translatable code in ThirdParty.jar needs to include plaintext *.java sources. E.g. com/example/shared/Widget.class and com/example/shared/Widget.java are both present
  • the ThirdParty.jar is on your classpath

Notes:

  • if the ThirdParty gwt module does not have entry point it does not need to be compiled with gwt compiler
  • the gwt compiler does not require extra configuration to include the ThirdParty module as long as its jar is on classpath and your *.gwt.xml inherits ThirdParty.gwt.xml; the same applies to the gwt maven plugin
Vlastimil Ovčáčík
  • 2,799
  • 27
  • 29