Public static resources (Javascript) missing after compiling with gwt-maven-plugin

92 views
Skip to first unread message

Julien

unread,
Jun 12, 2015, 11:59:45 AM6/12/15
to codehaus-mojo-gwt-...@googlegroups.com
Hi,

I hope someone can help me with this :)

I've a first GWT module which contains a javascript file (in 'public' folder) that is dynamically loaded with a ScriptInjector inside onModuleLoad().
This module is compiled to a .jar (which contains the javascript file).

I've a second GWT module which inherits from the first one. This module is compiled to a .war with the help of the gwt-maven-plugin.
The result of the compilation is not working because the javascript file from the module 1 is missing in the "webapp/*module*/" folder. It has not been copied during the compilation :/

Is there anything special I need to write in my pom.xml to resolve this ?
Am I Trying to do something wrong ?

I'm also using Eclipse, and when I try to compile the module 2 with the Google Plugin for Eclipse (right click on the project -> Google -> GWT Compile) it does copy the javascript file.
(the command triggered by the Google Plugin is simply :
java -Xmx512m com.google.gwt.dev.Compiler -logLevel INFO -style OBFUSCATED -war src/main/webapp com.example.Module)

Thank you for your help

Juan Pablo Gardella

unread,
Jun 12, 2015, 12:03:59 PM6/12/15
to codehaus-mojo-gwt-...@googlegroups.com
Make your first module as WAR.

--
You received this message because you are subscribed to the Google Groups "Codehaus Mojo gwt-maven-plugin Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codehaus-mojo-gwt-maven-...@googlegroups.com.
To post to this group, send email to codehaus-mojo-gwt-...@googlegroups.com.
Visit this group at http://groups.google.com/group/codehaus-mojo-gwt-maven-plugin-users.
For more options, visit https://groups.google.com/d/optout.

Thomas Broyer

unread,
Jun 12, 2015, 5:00:33 PM6/12/15
to codehaus-mojo-gwt-...@googlegroups.com, cindylam...@gmail.com
Are you expecting output to your source folder? You're doing but wrong.
Output should (and probably does) go into target/<artifactId>-<version>.

Julien

unread,
Jun 15, 2015, 5:11:13 AM6/15/15
to codehaus-mojo-gwt-...@googlegroups.com, cindylam...@gmail.com
Thank you for your answers,
Actually let me correct something from my first post: the javascript file is present in the target folder (and in the resulting war) but it is never updated.

I found out that it is because when I used the "GWT Compile" from the Google Plugin, it copied the javascript file (from module 1) in the source folder (of module 2), and now it is this one that is placed in the target directory by Maven (even if it has been updated in the module 1 jar).
If I manually delete this javascript file before compiling with Maven, then the good one is taken from the module 1 jar.

It's not a problem because now that my Maven configuration is good I won't use the Google Plugin anymore so I won't face this again.
But still, I don't know if it was the gwt-maven-plugin that was choosing the wrong javascript file, or the maven-war-plugin that was overwriting the good one with the wrong one, or something else...

Thomas Broyer

unread,
Jun 15, 2015, 6:14:55 AM6/15/15
to codehaus-mojo-gwt-...@googlegroups.com, cindylam...@gmail.com

On Monday, June 15, 2015 at 11:11:13 AM UTC+2, Julien wrote:
Thank you for your answers,
Actually let me correct something from my first post: the javascript file is present in the target folder (and in the resulting war) but it is never updated.

I found out that it is because when I used the "GWT Compile" from the Google Plugin, it copied the javascript file (from module 1) in the source folder (of module 2), and now it is this one that is placed in the target directory by Maven (even if it has been updated in the module 1 jar).
If I manually delete this javascript file before compiling with Maven, then the good one is taken from the module 1 jar.

It's not a problem because now that my Maven configuration is good I won't use the Google Plugin anymore so I won't face this again.
But still, I don't know if it was the gwt-maven-plugin that was choosing the wrong javascript file, or the maven-war-plugin that was overwriting the good one with the wrong one, or something else...

Is GWT really invoked during your Maven build when it "fails" to copy the file?
gwt-maven-plugin tries to detect when things are up-to-date and compilation can be skipped, but this is fragile, and actually a bug in GWT 2.7 totally breaks it.
When you *know* GWT should be invoked, call Maven with -Dgwt.compiler.force=true to bypass the staleness check and force the invocation.
 

Julien

unread,
Jun 15, 2015, 8:49:48 AM6/15/15
to codehaus-mojo-gwt-...@googlegroups.com, cindylam...@gmail.com
Yes GWT is invoked,
The "-Dgwt.compiler.force=true" does not help :/

When I said that it was not a problem, I was wrong... 
The GWT super dev mode needs and copy public resources in the source folder, so I need to find a way to make my maven building configuration deal with those files and use the jar if a newer version of a file is available.

I'm using GWT and gwt-maven-plugin 2.6.1, I've done some test with 2.7.0 but I want to stay with 2.6.1 if 2.7.0 does the same for my case.

Do you have any suggestion ?
Thank you in advance

Julien

unread,
Jun 16, 2015, 10:24:49 AM6/16/15
to codehaus-mojo-gwt-...@googlegroups.com
I'm now using GWT and gwt-maven-plugin 2.7.0.
I decided to switch because the super dev mode in GWT 2.6.1 did not handle well public ressources (not copying them on first launch for example), and this has been improved in 2.7.0.

Regarding the maven building, it still uses the resource file copyed in the source folder by the Google Plugin or the super dev mode even if there is a newer version in the jar of module 1.

For now I will just remember to remove old resources copyed in the source folder before building with maven.
If you find a workaround in the future please let me know.

Thomas Broyer

unread,
Jun 16, 2015, 12:53:38 PM6/16/15
to codehaus-mojo-gwt-...@googlegroups.com, cindylam...@gmail.com


On Tuesday, June 16, 2015 at 4:24:49 PM UTC+2, Julien wrote:
I'm now using GWT and gwt-maven-plugin 2.7.0.
I decided to switch because the super dev mode in GWT 2.6.1 did not handle well public ressources (not copying them on first launch for example), and this has been improved in 2.7.0.

Regarding the maven building, it still uses the resource file copyed in the source folder by the Google Plugin or the super dev mode even if there is a newer version in the jar of module 1.

For now I will just remember to remove old resources copyed in the source folder before building with maven.
If you find a workaround in the future please let me know.

You're not supposed to have anything generated in your source folder. If you have, then you're doing it wrong; and the behavior of preferring your sources over your dependencies is on-purpose.
The first time you launched DevMode from Eclipse, it should have asked you which folder to use as the "war" folder, and you should have picked your target/<artifactId>-<version>. I don't think it's possible to change it except by editing the appropriate file in your project's .settings/
I have no idea how the Google Plugin for Eclipse behaves when triggering the compilation though.

Julien

unread,
Jun 17, 2015, 6:49:15 AM6/17/15
to codehaus-mojo-gwt-...@googlegroups.com, cindylam...@gmail.com

Le mardi 16 juin 2015 18:53:38 UTC+2, Thomas Broyer a écrit :

You're not supposed to have anything generated in your source folder. If you have, then you're doing it wrong; and the behavior of preferring your sources over your dependencies is on-purpose.

You're so right, I don't wan't to have generated stuff in my source folder...
So the thing I was doing wrong was the configuration of the Google Plugin Dev mode launcher as you said.
Everything is explained to fix that in the link you provided, thanks !
And, as you said, because it was not the first time I launched it, Eclipse did not ask me which war folder to use so I went to "Run configuration" and change the -war argument in "Arguments" tab manually.

Thank you for your help and your work on GWT and gwt-maven-plugin ;)
Reply all
Reply to author
Forward
0 new messages