I'm trying to integrate this plugin in a multi-module project where:
- myapp is my root project
- myapp-common is a jar project containing common classes
- myapp-core is an ajb module containing my Spring+Hibernate backend
- myapp-gwt is my GWT module
- myapp-app is the ear module that combines all the previous modules
into one deployable ear.
I managed to set everything up with the default example application
and I deployed the ear to JBoss and everything worked fine with the
"click me" button. Then inside my entry point, I tried to import and
use classes from myapp-core module on which myapp-gwt depends in the
POM, and I had a problem on compilation because the compiler says it
can't find any of myapp-core classes. Here is myapp-gwt/pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.myapp</groupId>
<artifactId>myapp</artifactId>
<version>4.0.1-SNAPSHOT</version>
</parent>
<artifactId>myapp-gwt</artifactId>
<packaging>war</packaging>
<name>myapp GWT</name>
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>myapp-common</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>myapp-core</artifactId>
<version>${pom.version}</version>
<type>ejb</type>
</dependency>
<!--GWT dependencies-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.gwtx</groupId>
<artifactId>GWTx</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<targetPath>../${pom.artifactId}-${pom.version}</
targetPath>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.totsp.gwt</groupId>
<artifactId>maven-googlewebtoolkit2-plugin</
artifactId>
<configuration>
<logLevel>ALL</logLevel>
<gwtHome>C:/apps/gwt-windows-1.3.3</gwtHome>
<runTarget>com.myapp.myapp/myappHome.jsp</
runTarget>
<compileTarget>
<value>com.myapp.myapp</value>
</compileTarget>
<generatorRootClasses>com.myapp.server.myappBean</
generatorRootClasses>
<generatorDestinationPackage>com.myapp.client</
generatorDestinationPackage>
<generateGettersAndSetters>true</
generateGettersAndSetters>
</configuration>
<executions>
<execution>
<goals>
<!--<goal>mergewebxml</goal> -->
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Note that GWT plugin versions are specified in the
dependencyManagement section of the root POM.
Any idea of what is going wrong?
There are a number of important differences between normal-java-
classes and java-classes-for-gwt, among them:
The gwt-classes are transformed into javascript by the GWTCompiler, in
*one-step* and the classpath must contain the *java-sources*, not the
bytecode, but some times, even that is not enough!
When you want to separate your code as different jars, you have to use
the respective gwt notion of "modules".
You must then use the <inherit> element into the module.gwt.xml file
to mark that a module depends on another module.
In particular for your problem, you can't use the core package as a
common dependency for both ejb and war modules. That wouldn't make
any sense anyway, since the gwt part would run inside a JS-capable
browser, and the ejb, inside the app-server.
So, in a nutshell, you can either:
1) (simpler) duplicate all core-classes-for-gwt and place them inside
the war, underneath your gwt package(s),
2) create a new gwt-module to include the duplicated core classes, use
the mavensource-plugin to generate and install the sources, and then
add that sources artifact as a dependency of the war project, and also
inherit your war gwt-module from the new get-module .
A, you would most popably need to include the compiled bytecode jars
for the new module into war's dependencies (scoped as 'provided') for
stopping eclipse from screaming missing classes!
So it is too complicated...
All of the above (may) require a separate maven-module, but i'm not
sure, since i'm not using this maven-gwt-plugin.
You have to ask this group for specific instructions on the second
alternative.
With Regards,
Kostis
On May 16, 5:58 pm, sarbogast <sebastien.arbog...@gmail.com> wrote:
> Hi,
>
> I'm trying to integrate this plugin in a multi-module project where:
> - myapp is my root project
> - myapp-common is a jar project containing common classes
> - myapp-core is an ajb module containing my Spring+Hibernate backend
> - myapp-gwt is my GWT module
> - myapp-app is the ear module that combines all the previous modules
> into one deployable ear.
>
> I managed to set everything up with the default example application
> and I deployed the ear to JBoss and everything worked fine with the
> "click me" button. Then inside my entry point, I tried to import and
> use classes from myapp-core module on which myapp-gwt depends in the
> POM, and I had a problem on compilation because the compiler says it
> can't find any of myapp-core classes. Here is myapp-gwt/pom.xml
>
> <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.0http://maven.apache.org/maven-v4_0_0.xsd">
Here is a simplified copy of a module I'm working with. it has server
side and client side components in it, so its a normal dependency as
well as a GWT jar. THe jar will contain the class files, the GWT
module xml files and the source code, which is what that antrun hack
is all about.
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>sixgreen</groupId>
<artifactId>sixgreen-common-gwt</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Sixgreen GWT Common</name>
<description>Shared GWT Atrifacts</description>
<build>
<plugins>
...
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<configuration>
<tasks>
<copy
todir="${project.build.outputDirectory}">
<fileset
dir="${project.build.sourceDirectory}">
<include name="**/*.java" />
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
<dependencies>
...
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>1.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>1.3.3</version>
<classifier>windows</classifier>
<scope>provided</scope>
</dependency>
...
</dependencies>
</project>
<build>
<!-- All your plugins are here -->
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>
I've included this as well as the ant-run mechanism for completeness.
http://code.google.com/p/gwt-maven/wiki/FAQ
What I'm hoping to see is that the plugin uses the installed/deployed
source archive instead of this hack (like the codehous one does) but
until that time, we're stuck with alternatives.
To enable deployment of source as well as bin, use this plugin:
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
I currently publish source to our internal repo so that when the
option finally does show up, I'll be all set :)
- Brill
It looks like they simply add the source dependency during dependency
resolution, which is then included by the Maven engine.
You can check out their code and take a look... if I have time (not
likely int he near future, I can try and investigate.
you can simply add the plugin:
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
and you will see it work when you deploy. the POM and/or the meta data
should indicate the classifier.
- Brill Pappin
On May 29, 5:06 pm, "Robert \"kebernet\" Cooper" <keber...@gmail.com>
wrote:
> Do you know how they are doing that? Making the source dist jar a
> dependency? I mean, it seems you could just declare a dep on the source jar,
> and add the maven-source-pluging stuff to your project..
>
> Im not sure, though. It just seems the best-case for GWT stuff is to have a
> unified bytecode/source jar file.
>
see the section: Creating a Custom Artifact Handler
at: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
and a bit more at:
http://maven.apache.org/plugins/maven-deploy-plugin/examples/deployfile/deploying-with-classifiers.html
- Brill Pappin
On May 29, 5:06 pm, "Robert \"kebernet\" Cooper" <keber...@gmail.com>
wrote: