Using tbroyer/gwt-maven-plugin for project using Firebase, GWT 2.8, Polymer and JDK 1.8

253 views
Skip to first unread message

phine...@gmail.com

unread,
Jun 10, 2015, 10:19:17 AM6/10/15
to codehaus-mojo-gwt-...@googlegroups.com
Hi,

I'm starting a new, experimental GWT project that will use Firebase on the server side, so it doesn't have the typical 'shared' and 'server' code that many GWT projects do. I've used gwt-maven-plugin/gwt-maven-plugin in the past, but want to make a clean break and use the tbroyer/gwt-maven-plugin, as this looks cleaner with its multi-module approach.

I'd like to use Polymer and Firebase on the client side through JsInterop, so I'll be using GWT 2.8.0-SNAPSHOT and, hopefully, JDK 1.8 so I can use lambdas.

I started by using "modular-webapp" from the gwt-maven-archetypes, and stripping out the shared and server modules then adding my own web module. It's getting there, but as I'm starting my project I'm running into some questions:
  1. I'm planning on having three modules: A) one with GWT client code, B) one that contains the static host page and any other static content and C) one that contains some nodejs worker code that accesses Firebase to do some server side processing. Do these make sense?
  2. Is it possible to have one development goal that starts a servlet container that could serve both the client host page as well as the GWT code server for super dev mode? Right now I run the code server out of the client module and a jetty instance (jetty:run) separately out of the static content module, but development could be a little easier than making this extra step.
  3. I'm getting many errors when running gwt:compile on my client module like this: "Errors in 'jar:file:/Users/me/.m2/repository/com/google/gwt/gwt-dev/2.8.0-SNAPSHOT/gwt-dev-2.8.0-SNAPSHOT.jar!/com/google/gwt/dev/util/arg/OptionExtraDir.java' Line 28: No source code is available for type java.io.File; did you forget to inherit a required module?" so I've probably missed something in my pom.xml, but am not seeing it. I've included my top level, client and web pom.xml files, in case that helps.
Thanks for any help getting started on this, or other tips that might be useful. I feel like not many people have gone down a similar path, but maybe there will be others in the future after GWT 2.8 is released and people get into Polymer and Firebase.

(Note: groupId and artifactId below are given for example purposes)

/pom.xml (top level)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   
<modelVersion>4.0.0</modelVersion>

   
<groupId>myproject</groupId>
   
<artifactId>myproject</artifactId>
   
<version>0.1.0-SNAPSHOT</version>
   
<packaging>pom</packaging>

   
<prerequisites>
       
<maven>${mavenVersion}</maven>
   
</prerequisites>

   
<properties>
       
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

       
<gwt.version>2.8.0-SNAPSHOT</gwt.version>
       
<maven.compiler.source>1.8</maven.compiler.source>
       
<maven.compiler.target>1.8</maven.compiler.target>

       
<mavenVersion>3.0</mavenVersion>
   
</properties>

   
<dependencyManagement>
       
<dependencies>
           
<dependency>
               
<groupId>com.google.gwt</groupId>
               
<artifactId>gwt</artifactId>
               
<version>${gwt.version}</version>
               
<type>pom</type>
               
<scope>import</scope>
           
</dependency>
       
</dependencies>
   
</dependencyManagement>

   
<build>
       
<plugins>
           
<plugin>
               
<groupId>net.ltgt.gwt.maven</groupId>
               
<artifactId>gwt-maven-plugin</artifactId>
               
<inherited>false</inherited>
               
<configuration>
                   
<moduleName>mymodule</moduleName>
                   
<launcherDir>${project.build.directory}/gwt/launcherDir</launcherDir>
               
</configuration>
           
</plugin>
       
</plugins>
       
<pluginManagement>
           
<plugins>
               
<plugin>
                   
<artifactId>maven-compiler-plugin</artifactId>
                   
<version>3.2</version>
                   
<configuration>
                       
<source>${maven.compiler.source}</source>
                       
<target>${maven.compiler.target}</target>
                   
</configuration>
               
</plugin>
               
<plugin>
                   
<groupId>org.eclipse.jetty</groupId>
                   
<artifactId>jetty-maven-plugin</artifactId>
                   
<version>9.2.11.v20150529</version>
               
</plugin>
               
<plugin>
                   
<groupId>net.ltgt.gwt.maven</groupId>
                   
<artifactId>gwt-maven-plugin</artifactId>
                   
<version>1.0-beta-2</version>
                   
<extensions>true</extensions>
                   
<configuration>
                       
<sourceLevel>${maven.compiler.source}</sourceLevel>
                       
<failOnError>true</failOnError>
                   
</configuration>
               
</plugin>
               
<plugin>
                   
<artifactId>maven-source-plugin</artifactId>
                   
<version>2.4</version>
                   
<executions>
                       
<execution>
                           
<id>attach-sources</id>
                           
<phase>package</phase>
                           
<goals>
                               
<goal>jar-no-fork</goal>
                           
</goals>
                       
</execution>
                   
</executions>
               
</plugin>
           
</plugins>
       
</pluginManagement>
   
</build>
   
<modules>
       
<module>my-client</module>
       
<module>my-web</module>
   
</modules>
</project>

/my-client/pom.xml (contains GWT client code)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   
<modelVersion>4.0.0</modelVersion>

   
<parent>
       
<groupId>myproject</groupId>
       
<artifactId>myproject</artifactId>
       
<version>0.1.0-SNAPSHOT</version>
   
</parent>

   
<artifactId>myproject-client</artifactId>
   
<packaging>gwt-app</packaging>

   
<prerequisites>
       
<maven>${mavenVersion}</maven>
   
</prerequisites>

   
<dependencies>
       
<dependency>
           
<groupId>com.google.gwt</groupId>
           
<artifactId>gwt-user</artifactId>
       
</dependency>
       
<dependency>
           
<groupId>com.google.gwt</groupId>
           
<artifactId>gwt-dev</artifactId>
       
</dependency>
       
<dependency>
           
<groupId>com.google.gwt</groupId>
           
<artifactId>gwt-codeserver</artifactId>
       
</dependency>
   
</dependencies>

   
<build>
       
<plugins>
           
<plugin>
               
<groupId>net.ltgt.gwt.maven</groupId>
               
<artifactId>gwt-maven-plugin</artifactId>
               
<configuration>
                   
<moduleName>mymodule</moduleName>
                   
<moduleShortName>mymodule</moduleShortName>
               
</configuration>
           
</plugin>
       
</plugins>
   
</build>
</project>

/my-web/pom.xml (contains host page and static content)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   
<modelVersion>4.0.0</modelVersion>

   
<parent>
       
<groupId>myproject</groupId>
       
<artifactId>myproject</artifactId>
       
<version>0.1.0-SNAPSHOT</version>
   
</parent>

   
<artifactId>myproject-web</artifactId>
   
<packaging>war</packaging>

   
<prerequisites>
       
<maven>${mavenVersion}</maven>
   
</prerequisites>

   
<build>
       
<finalName>myproject</finalName>
   
</build>
</project>



phine...@gmail.com

unread,
Jun 11, 2015, 7:44:38 AM6/11/15
to codehaus-mojo-gwt-...@googlegroups.com
Hi,

The reason for the errors in #3 was actually not in my pom.xml files, but that I had specified the source path in my module.gwt.xml file as:

<source path="" />

when it needed to be fully specified:

<source path="com/package" />

Now it's compiling on JDK 1.8 with GWT 2.8.0-SNAPSHOT. Will keep working on #1 and #2 and report back on how it goes. 

Thomas Broyer

unread,
Jun 11, 2015, 9:07:14 AM6/11/15
to codehaus-mojo-gwt-...@googlegroups.com, phine...@gmail.com


On Thursday, June 11, 2015 at 1:44:38 PM UTC+2, phine...@gmail.com wrote:
Hi,

The reason for the errors in #3 was actually not in my pom.xml files, but that I had specified the source path in my module.gwt.xml file as:

<source path="" />

when it needed to be fully specified:

<source path="com/package" />

Now it's compiling on JDK 1.8 with GWT 2.8.0-SNAPSHOT.

I'd rather say your moduleName should have been com.package.MyModule.
 

phine...@gmail.com

unread,
Jun 11, 2015, 10:02:47 AM6/11/15
to codehaus-mojo-gwt-...@googlegroups.com, phine...@gmail.com
I was using the module.gwt.xml file created by the modular-webapp archetype, which when I created it ended up at:

./myproject-client/src/main/module.gwt.xml

I then had to move it into the java directory after it couldn't be found when running "mvn package" at the top level. Then it found it, but since I didn't change the source path, it tried to compile everything in my classpath to JavaScript. I had to either change the source path, or I could have moved module.gwt.xml under ./myproject-client/src/main/java/com/package.

But I'm not sure how the build would find module.gwt.xml outside of the java directory, as it is generated by the archetype...

Thomas Broyer

unread,
Jun 11, 2015, 12:44:11 PM6/11/15
to codehaus-mojo-gwt-...@googlegroups.com, phine...@gmail.com


On Thursday, June 11, 2015 at 4:02:47 PM UTC+2, phine...@gmail.com wrote:
I was using the module.gwt.xml file created by the modular-webapp archetype, which when I created it ended up at:

./myproject-client/src/main/module.gwt.xml

I then had to move it into the java directory after it couldn't be found when running "mvn package" at the top level. Then it found it, but since I didn't change the source path, it tried to compile everything in my classpath to JavaScript. I had to either change the source path, or I could have moved module.gwt.xml under ./myproject-client/src/main/java/com/package.

But I'm not sure how the build would find module.gwt.xml outside of the java directory, as it is generated by the archetype...


The gwt-maven-plugin's generate-module goal will copy and process it. See https://tbroyer.github.io/gwt-maven-plugin/generate-module-mojo.html
And it's bound to the generate-resources phase with the gwt-lib and gwt-app lifecycles: https://tbroyer.github.io/gwt-maven-plugin/lifecycles.html

Thomas Broyer

unread,
Jul 11, 2015, 8:00:27 PM7/11/15
to codehaus-mojo-gwt-...@googlegroups.com, phine...@gmail.com


On Wednesday, June 10, 2015 at 4:19:17 PM UTC+2, phine...@gmail.com wrote:
Hi,

I'm starting a new, experimental GWT project that will use Firebase on the server side, so it doesn't have the typical 'shared' and 'server' code that many GWT projects do. I've used gwt-maven-plugin/gwt-maven-plugin in the past, but want to make a clean break and use the tbroyer/gwt-maven-plugin, as this looks cleaner with its multi-module approach.

I'd like to use Polymer and Firebase on the client side through JsInterop, so I'll be using GWT 2.8.0-SNAPSHOT and, hopefully, JDK 1.8 so I can use lambdas.

I started by using "modular-webapp" from the gwt-maven-archetypes, and stripping out the shared and server modules then adding my own web module. It's getting there, but as I'm starting my project I'm running into some questions:
  1. I'm planning on having three modules: A) one with GWT client code, B) one that contains the static host page and any other static content and C) one that contains some nodejs worker code that accesses Firebase to do some server side processing. Do these make sense?
  2. Is it possible to have one development goal that starts a servlet container that could serve both the client host page as well as the GWT code server for super dev mode? Right now I run the code server out of the client module and a jetty instance (jetty:run) separately out of the static content module, but development could be a little easier than making this extra step.

FWIW, I added a gwt:devmode goal in 1.0-rc-1 (and just released 1.0-rc-2 with some fixes) to run/debug standalone apps: https://tbroyer.github.io/gwt-maven-plugin/codeserver.html#Standalone_applications
Reply all
Reply to author
Forward
0 new messages