开发者

GWT getting an inherited module on the compiler's classpath

开发者 https://www.devze.com 2023-03-07 02:40 出处:网络
I have a project with multiple gwt modules, one of which is a library module without an entry point from which the other modules inherit.All the modules are contained in a single project built using m

I have a project with multiple gwt modules, one of which is a library module without an entry point from which the other modules inherit. All the modules are contained in a single project built using maven and the gwt-maven-plugin. Unfortunately, building the project fails because gwt:compile is looking for the inhe开发者_如何学JAVArited module on the classpath when it compiles the main modules that inherit it. How do I get the library module on the classpath for the compilation of the main modules?


You're going to need to do some creative "Maven-ing," as I just made up the term to describe it. (In reality it probably isn't creative at all, but I'm a bit of a Maven newbie myself, so it stumped me for a while too).

You're right in a sense, the GWT comipler is looking for the inherited module's source on the classpath when it tries to compile your "main" module. To achieve this, you will need to add a dependency, to the main module's pom, on the library module's sources (strictly for the compile phase).

Something like this:

...
<artifactId>main-module</artifactId>
...
<dependency>
  <groupId>library-group</groupId>
  <artifactId>library-artifact</artifactId>
  <type>jar</type>
  <version>0.1-SNAPSHOT</version>
  <classifier>sources</classifier>
  <scope>compile</scope>
</dependency>
...

Now, where you get those sources from can differ. If you're just trying to do this from an IDE, like Eclipse, this is probably enough because the m2eclipse plugin is smart enough to know where to get those sources (if the library-module is also in your workspace). If this is your actual build process, then you will need to modify the library-module's pom to produce the -sources artifact along with the standard "library-artifact." So you'll end up with both:

library-artifact-0.1-SNAPSHOT.jar

and

library-artifact-0.1-SNAPSHOT-sources.jar

Hopefully it's more clear how the gwt-maven-plugin proceeds from that point.

Almost forgot, the one other question I've answered here might be of some use as well: GWT Project Structure.


Ok, I was able to solve this by explicitly listing my GWT modules in the project's pom file's gwt-maven-plugin configuration. By doing this, I was able to enforce the order of GWT compilation, ensuring that the shared module was compiled first and available to the other modules that inherit from it during their compilations.

Here is an example of the config:

<configuration>
  <modules>
    <module>com.foo.gwt.shared.Shared</module>
    <module>com.foo.feature.one.gwt.One</module>
    <module>com.foo.feature.two.gwt.Two</module>
  </modules>
</configuration>

Thanks to Jason482 for all the help.


I would have preferred to comment on the answer above but I do not have enough rep to do it. So I am posting my findings here.

Jason482's answer worked for me. Adding:

<classifier>sources</classifier> <scope>compile</scope>

to each of my sub-modules dependencies, inside the reactor pom, solved my issue.

The solution that mreynolds went with, adding GWT module references to the main pom file's gwt-maven-plugin configuration, seems to be necessary ONLY if you have other entry points in your GWT submodules. I did not, so that step was not necessary for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消