Including a submodule of a gwt project in maven

107 views
Skip to first unread message

Elhanan

unread,
Oct 18, 2020, 6:48:30 AM10/18/20
to GWT Users
hi..
i have a submodule of a gwt project that it's artifact are meant to be included as part of the main artifact (which is a pom containing a debian installer) 
usually i would use copy-depdencies plugin to copy the jars into the main artifact, but in this case there's no jar, is there a way i can copy the output directory of that submodule into the main artifact? 

lofid...@gmail.com

unread,
Oct 18, 2020, 10:48:43 AM10/18/20
to GWT Users
Is it not possible to add those contents into an artifact with assembly for example? So that you can use it later for the dependency? I'm doing this in this example:

Hope this helps.

Elhanan Maayan

unread,
Oct 18, 2020, 10:55:35 AM10/18/20
to google-we...@googlegroups.com
i don't know, right now i'm having trouble to even compile everything, i mean, i can either compile all the static files  (html WEB-INF) into a war, OR i can compile the gwt sources, depending on what i place in pom.xml (gwt-app or war) i was trying to have it all in one module

--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/42DICj36J0E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/38ff23af-b3d7-4aef-80e8-9451486aa641n%40googlegroups.com.

lofid...@gmail.com

unread,
Oct 18, 2020, 10:59:25 AM10/18/20
to GWT Users
Hmm it is not good to have "server" part and "client" part (web browser, GWT) in one Maven module... The best practice is always to separate them.

I wrote some simple explanation in this project: https://github.com/gwtboot/domino-rest-enum-date with 3 Maven modules, check the explanation over there...

Elhanan Maayan

unread,
Oct 18, 2020, 11:03:21 AM10/18/20
to google-we...@googlegroups.com
yes, i understand that gwt-maven-plugin is "opinionated" (i.e forces me to do it) and i'm in the process of doing so, the thing is there's no "Server part" it's meant to operate as a page under cockpit ui 

lofid...@gmail.com

unread,
Oct 18, 2020, 11:23:07 AM10/18/20
to GWT Users
In my example I only use the gwt-maven-plugin for the "client" part (GWT part). On the server part I use "pure" Spring Boot approach, therefore I copied all the JS stuffs from the "client" part with the help of maven-dependencies-plugin. I'm not using war deployment on Spring Boot...

For me the main concept: From GWT project you get just JS file(s) and you can copy it somewhere else where you have a web server. I also already use "only" the JS file(s) and copy the automatically to NGinX without server part.

Elhanan Maayan

unread,
Oct 18, 2020, 11:28:19 AM10/18/20
to google-we...@googlegroups.com
i'm assuming those 2 need to be in there own aggregator pom (i.e my main parent pom will a web ui pom, which will have those submodules) , because i want to be able to build just that webproject alone without the need to build the whole project again (this is because that in order to develop for cockpit i can't use any of the rapid inplace server development, but compile the while thing and copy the distro to a linux server running the cockpit server)

lofid...@gmail.com

unread,
Oct 18, 2020, 1:01:39 PM10/18/20
to GWT Users
I cannot follow you, maybe you could write something like:

cockpit
-- cockpit-client-ui
-- cockpit-server
...

I'm not sure how the structure of your projects looks like?

Elhanan Maayan

unread,
Oct 18, 2020, 1:06:45 PM10/18/20
to google-we...@googlegroups.com
i did just that only it's more like 
main_pom
--mod1
--mod2
--webui
----webui-client
----webui-server 
--builder-mod that collects all jars from other modes into a directory for final deploy and installation 

what i wanna do is also be able to build only the webui project, and possibility to use the codeserver option which i don't think i can now because they are all split in 3 modules

lofid...@gmail.com

unread,
Oct 18, 2020, 1:24:09 PM10/18/20
to GWT Users
--webui
----webui-client ---> this is the GWT code
----webui-server ---> this is server-side code like Servlet, Spring Boot, JavaEE servers

This is the standard layout for maven-gwt-plugin so would be no problem at all... and for the mod1 / mod2: as long as you do: install, the webui-client (gwt codeserver) will recognize the "source code" and could also transpile the code on the fly... (at least the last time I check it out)...

If you want to completely separate everything you could go for:

--modules
----mod1
----mod2

--webui
----webui-client
----webui-server 

--builder-modules

Elhanan Maayan

unread,
Oct 18, 2020, 1:28:19 PM10/18/20
to google-we...@googlegroups.com
but the webui-server contains all the static resources like the html page 

lofid...@gmail.com

unread,
Oct 18, 2020, 2:16:56 PM10/18/20
to GWT Users
Yes, but that's not a problem... in my example above I took out the html file (https://github.com/gwtboot/domino-rest-enum-date/blob/master/domino-rest-enum-date-client/src/assembly/distribution.xml) so that I only packaged the JS files... and at the end I use the HTML files from the server part.

IMHO it is always good to be able to implement the "client" without the server part. I always mock the whole "server part"...

Elhanan Maayan

unread,
Oct 18, 2020, 3:32:27 PM10/18/20
to google-we...@googlegroups.com
i missing something basic here with all the code server/dev mode/super dev mode/launch dir/workdir/startup url/s 
at the end of the day you have to have an html file to use, when you launch for debug, but the gwt plugins are in the client module which doesn't have the html file on one hand, but they compile and write to the server module on other hand. 

lofid...@gmail.com

unread,
Oct 18, 2020, 3:53:16 PM10/18/20
to GWT Users
Yes correct, HTML file is your host file.

I always put a simple HTML file to be able to launch / debug gwt webapp on the client... see: https://github.com/gwtboot/domino-rest-enum-date/blob/master/domino-rest-enum-date-client/src/main/java/com/example/public/index.html

But you don't have to use the same HTML file for client and server. On the server side I also have a HTML file: https://github.com/gwtboot/domino-rest-enum-date/blob/master/domino-rest-enum-date-server/src/main/resources/static/index.html which is a bit different.

The main artifact from "client" is the JS file which you can insert everywhere in a HTML file (server, etc.)

lofid...@gmail.com

unread,
Oct 18, 2020, 4:33:42 PM10/18/20
to GWT Users
additionally ... in the case using the structure of gwt-maven-plugin also correct.

There are two possibilities using gwt:codeserver (the case you said) or gwt:devmode (my example) see the difference: https://tbroyer.github.io/gwt-maven-plugin/codeserver.html

Both possible, I just prefer the second one ("standalone") because I try not to mix both world... Spring Boot stays like Spring Boot and the development of UI (client) should always be standalone and all the server parts should be mocked...

Elhanan Maayan

unread,
Oct 18, 2020, 4:53:31 PM10/18/20
to google-we...@googlegroups.com
yes, but in addition to the html file your also have the css files as well.. 

lofid...@gmail.com

unread,
Oct 18, 2020, 5:30:09 PM10/18/20
to GWT Users
Yes and you can control it using Maven assembly as I showed above

You can add the CSS files to be added to the server module on deployment...

But again, of course you can use gwt:codeserver instead of standalone gwt:devmode 

Elhanan Maayan

unread,
Oct 18, 2020, 5:35:23 PM10/18/20
to google-we...@googlegroups.com
essentially i could use all the real static files in the client side 

lofid...@gmail.com

unread,
Oct 18, 2020, 5:43:33 PM10/18/20
to GWT Users
Yes, the main thing you have a fast turn around time for compile - test cycle for UI development. Because if you are working on UI you don‘t care about the business logic on the server. You just need some data examples which you can mock easily with your DTO...

Elhanan Maayan

unread,
Oct 18, 2020, 5:58:10 PM10/18/20
to google-we...@googlegroups.com
thanks, btw i don't understand why the maven plugin insists on compiling it for devmode

Dr. Lofi Dewanto

unread,
Oct 18, 2020, 6:30:11 PM10/18/20
to google-we...@googlegroups.com
Hmmm do you mean, maven-gwt-plugin compiles / transpiles everything first before it starts with gwt:devmode? ... Actually it doesn't need to, I agree... maybe @tbroyer could explain?

Elhanan Maayan

unread,
Oct 19, 2020, 3:59:59 AM10/19/20
to google-we...@googlegroups.com
no i meant, that when i do regular compile i still see *.devmode.* files on the target dir, and when i try to use just a normal server, it says it can't see the codeserver.

Dr. Lofi Dewanto

unread,
Oct 19, 2020, 4:44:44 AM10/19/20
to google-we...@googlegroups.com
Hmm ok... Never take a look at that...

Elhanan Maayan

unread,
Oct 19, 2020, 5:30:22 AM10/19/20
to google-we...@googlegroups.com
I also understand that tbroyer is against doing maven install in general, which is what i intend to do as it's part of the whole build process,  all i need is for the the entire output be recognized as an artifact to be carried to he main build , the solution your provider with the assembly seems to so if, so i won't even need the server side, and just have that pom copy instructions executed on the build module 
Although in the future i may have a server side just to be able to execute shell commands 

Thomas Broyer

unread,
Oct 19, 2020, 5:47:50 AM10/19/20
to GWT Users
I haven't followed the whole discussion, but if you don't have a need for shared and server modules (what I call a "standalone" app), then you can put your HTML file (and associated resources) into your module's public path.
You'll then use gwt:devmode for debugging, to take advantage of the embedded web server to serve your static resources; see https://tbroyer.github.io/gwt-maven-plugin/codeserver.html#Standalone_applications
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsub...@googlegroups.com.

Elhanan Maayan

unread,
Oct 19, 2020, 7:59:16 AM10/19/20
to google-we...@googlegroups.com
hey thomas, the thing is, i wanna do it right without any hacks, but if i demine the pom as gwt-app, the output is just gwt compiled code  with no static html or css resources, if i use war in the pom type, the output is just the static resources. i want the entire artifact to be considered as both html and gwt javascript. 

--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/42DICj36J0E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.

Elhanan Maayan

unread,
Oct 19, 2020, 10:43:26 AM10/19/20
to google-we...@googlegroups.com
what's the difference between 
warDir, webappDirectory, workDir,workingDirectory, codeServerWorkDir , devModeWorkDir, tempDir? 
i mean it's hard to follow all those around.

lofid...@gmail.com

unread,
Oct 19, 2020, 12:05:30 PM10/19/20
to GWT Users
😀Therefore I'm using the simplest gwt:devmode... Standalone is the best... only <startupUrls>

But I think you could just use the default dirs...

Thomas Broyer

unread,
Oct 19, 2020, 12:45:54 PM10/19/20
to GWT Users
If you put your static resources in the public path of your module (by default a "public" subpackage next to your *.gwt.xml file), they'll be copied (by GWT itself, not the gwt-maven-plugin) to the output next to the *.nocache.js and *.cache.* files, so they'll end up in your WAR.
The only difference with using a "more standard" src/main/webapp is that if your GWT module has rename-to="myapp", then everything will be in the "myapp/" folder.
E.g. you create a src/main/resources/com/example/myapp/public/index.html with a <script src="myapp.nocache.js"></script> (notice: myapp.nocache.js, not myapp/myapp.nocache.js), then you have a myapp/index.html and myapp/myapp.nocache.js in your WAR.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsub...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/42DICj36J0E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsub...@googlegroups.com.

Thomas Broyer

unread,
Oct 19, 2020, 12:57:22 PM10/19/20
to GWT Users


On Monday, October 19, 2020 at 4:43:26 PM UTC+2, Elhanan wrote:
what's the difference between 
warDir, webappDirectory, workDir,workingDirectory, codeServerWorkDir , devModeWorkDir, tempDir? 
i mean it's hard to follow all those around.

I'm assuming you're using autocompletion in your IDE here, then yes it's hard to understand. That's why we have docs ;-)
gwt:compile outputs to webappDirectory, and puts its own files into workDir (they will be reused between runs for better performance); webappDirectory should match outputDirectory and warName of gwt:package-app for everything to run smoothly.
gwt:devmode uses warDir and devModeWorkDir, with approximately the same meaning as webappDirectory and workDir of gwt:compile, respectively.
gwt:codeserver writes to codeServerWorkDir, and possibly launcherDir (which is where your –separate– web server would serve static resources)
tempDir comes from gwt:test, it's inherited from Surefire; gwt:test also has a workDir which can be shared with gwt:compile (other work dirs don't have the same layout)
Reply all
Reply to author
Forward
0 new messages