"client" code from external directory

22 views
Skip to first unread message

Alex Shabanov

unread,
Oct 25, 2010, 7:22:07 AM10/25/10
to Google Web Toolkit
Hi all,

I have a GWT module in my maven project which structure is as follows:

/project-root
|
pom.xml
|
/gwt-module {<< uses general-constants}
| |
| pom.xml
| ...
|
/other-module {<< uses general-constants as well}
| |
| pom.xml
| ...
|
/general-constants {independent from others, but located in the
same parent project layout}
|
pom.xml
/src/main/java/pathomitted/
|
Constants1.java
Constants2.java

ConstantsX.java looks as follows:

public final class ConstantsX {
public final static int CONSTANT1 = 19;
public final static String CONSTANT2 = "^\\d{3,4}$";
// ...

private ConstantsX() {} // ctor is hidden
}

Basically general-constants is a module that defines some reusable
integer and string constants that I want to use in the GWT module and
some other non-GWT modules.

The question is how to make files in the module general-constants
available to GWT module by including external java files using
relative pathname to the another dir, like this one: ../general-
constants/src/main/java/pathomitted/*?

The solution obviously would look like a hack but I still think it is
better than code duplication.

And I wouldn't like to put any GWT-related stuff to the general-
constants module which clearly should be independent from the others.

P.S.: I didn't find the clear yes or no answer on Google, so I'm
asking here.

Thomas Broyer

unread,
Oct 25, 2010, 2:33:58 PM10/25/10
to Google Web Toolkit

Alex Shabanov

unread,
Oct 26, 2010, 12:19:20 PM10/26/10
to Google Web Toolkit
Thank you so much for your advice.

I've created a small proof-of-concept project (available for svn,
revision 291: svn co http://webkit-jspf.googlecode.com/svn/trunk/tmp/maven/gwt-external-lib
gwt-external-lib)

Basically it's structure follows the one I described above, there is a
generic module that defines Constants class with two public static
constants and there is a gwt module "gwtmod" that includes the generic
module and uses it's Constants class.

To make Constants available for gwtmod I've added corresponding
compileSourcesArtifacts entry to it's gwt-maven-plugin's configuration
section, added Generic.gwt.xml that refers to the sources from generic
module's domain and included Generic module in the
Application.gwt.xml.
GWT compilation fails:
[INFO] com.mysite.generic.Generic is up to date. GWT compilation
skipped
[INFO] Compiling module com.mysite.gwtmod.Application
[INFO] Validating newly compiled units
[INFO] [ERROR] Errors in 'file:/home/alex/proj/googlecode-webkit-
jspf/tmp/maven/gwt-external-lib/gwtmod/src/main/java/com/mysite/gwtmod/
client/Application.java'
[INFO] [ERROR] Line 16: No source code is available for type
com.mysite.generic.Constants; did you forget to inherit a required
module?

- it sees Generic module but omits it's compilation because maven
thinks that it is "up to date". And yes, I did mvn clean install.

Any help greatly appreciated!

On Oct 25, 10:33 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> On 25 oct, 13:22, Alex Shabanov <avshaba...@gmail.com> wrote:
>>...

Alex Shabanov

unread,
Oct 31, 2010, 2:59:11 PM10/31/10
to Google Web Toolkit
Guys, can anybody help me, please?

The solution should be pretty simple but I still can't figure out what
is the problem.

Does someone ever tried the approach given above?

On Oct 26, 8:19 pm, Alex Shabanov <avshaba...@gmail.com> wrote:
> Thank you so much for your advice.
>
> I've created a small proof-of-concept project (available for svn,
> revision 291: svn cohttp://webkit-jspf.googlecode.com/svn/trunk/tmp/maven/gwt-external-lib

Jeff Larsen

unread,
Oct 31, 2010, 7:21:15 PM10/31/10
to Google Web Toolkit
Put a gwt.xml file in the project.

define the module, then you'll be able to import your library project
into a gwt project.

Alex Shabanov

unread,
Nov 1, 2010, 4:21:12 AM11/1/10
to Google Web Toolkit
Thank you for attention for my problem.

On Nov 1, 3:21 am, Jeff Larsen <larse...@gmail.com> wrote:
> Put a gwt.xml file in the project.

I did. It's name is Generic.gwt.xml.

>
> define the module, then you'll be able to import your library project
> into a gwt project.

The same thing, yes I defined the module (Generic.gwt.xml), but it
never compiles:
>> [INFO] com.mysite.generic.Generic is up to date. GWT compilation
skipped

This results in the subsequent error in Application module because it
uses Constants type defined in the Generic module.

>
> ...

By the way, the sources of the sample application is available, just
do svn checkout http://webkit-jspf.googlecode.com/svn/trunk/tmp/maven/gwt-external-lib
It compiles without errors if the usages of Constants type are
commented.

Alex Shabanov

unread,
Nov 1, 2010, 8:39:33 AM11/1/10
to Google Web Toolkit
I've just found out the error.

At first, maven-gwt-plugin must be of 1.3.1.version, ver 1.2 that is
available in the "official" maven repository does not support
compileSourcesArtifacts tag.
The other problem is that I tried to include generic module by adding
Generic.gwt.xml in gwtmod module, but this file must be located in the
resources of the distributed library, i.e. in generic module's
resources.

Though it's a pity that I can't use relative path in the gwtmod, e.g.
telling GWT compiler to use sources from, say, ../another-project/main/
java/** path - to not to modify external library's source code and
maven configuration. And I guess this is not that bad because exported
module must be checked early by the GWT compiler for using only the
emulated part of the JRE.

On Nov 1, 11:21 am, Alex Shabanov <avshaba...@gmail.com> wrote:
> Thank you for attention for my problem.
>
> On Nov 1, 3:21 am, Jeff Larsen <larse...@gmail.com> wrote:
>
> > Put a gwt.xml file in the project.
>
> I did. It's name is Generic.gwt.xml.
>
>
>
> > define the module, then you'll be able to import your library project
> > into a gwt project.
>
> The same thing, yes I defined the module (Generic.gwt.xml), but it
> never compiles:>> [INFO] com.mysite.generic.Generic is up to date. GWT compilation
>
> skipped
>
> This results in the subsequent error in Application module because it
> uses Constants type defined in the Generic module.
>
>
>
> > ...
>
> By the way, the sources of the sample application is available, just
> do svn checkouthttp://webkit-jspf.googlecode.com/svn/trunk/tmp/maven/gwt-external-lib
Reply all
Reply to author
Forward
0 new messages