0

When using gwt-maven-plugin's generateAsync, is it possible to apply an annotation (or something) to an individual gwt-rpc service so that the corresponding async isn't auto-generated and can be written manually?


Alternatively, is there an annotation (or something) that makes the generated asyncs have the "Request" return type?

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
CasualT
  • 4,869
  • 1
  • 31
  • 53

2 Answers2

0

The GWT Generators will never create a class if one already exists with that name. This means you can ask GWT to compile and generate the code, then copy the classes into your sources and customize them, and later compiler runs will not attempt to generate sources.

This may have other side effects - if the proxy, typeserializer, or fieldserializer is prevented from being generated, then the RPC generators may assume that other dependencies have also all been correctly generated, so you may find yourself missing classes if you don't also copy those other classes. Likewise, of course any changes that require your serializers being modified or rebuilt will have to be done manually, such as changing a serializable type, or modifying a RPC method.


Your async interface can always declare a return type of Request or RequestBuilder instead of void. If you declare RequestBuilder, then the request will not be sent automatically, and you must call send(), whereas a Request returned means that the request has been sent.

Colin Alworth
  • 17,801
  • 2
  • 26
  • 39
  • Is there a way to have the autogenerated ones use a Request/Request builder? – CasualT Mar 30 '16 at 23:25
  • Also, I'm definitely seeing the classes get generated when they already exist, but I'm thinking that is because the gwt-maven-plugin is not as discerning. – CasualT Mar 30 '16 at 23:28
  • "Is there a way...?" Yes, simply make your async methods return Request or RequestBuilder instead of void. The generated classes in maven should be in `target/.generated/...`, though you may need to turn a flag on to force them to show up on disk (there are two gwt-maven-plugins, I can't see which you are using). – Colin Alworth Mar 31 '16 at 13:35
  • I currently have hand-written async methods, with Request value returned, so yes, I know how to do that. And yes, I do see the generated ones, that isn't the problem. (We use this plugin I believe: https://gwt-maven-plugin.github.io/gwt-maven-plugin/). – CasualT Mar 31 '16 at 20:29
  • If you have more specifics, update your question - comments aren't the place to have a discussion. – Colin Alworth Mar 31 '16 at 20:34
  • you seemed confused. sorry. – CasualT Mar 31 '16 at 22:08
0

From the gwt-maven-plugin's documentation you need to adjust the servicePattern configuration property, or you can ask it to always generate methods returning Request.

Or, even better, don't use this goal!

(or only call it manually once in a while and copy the generated classes to your sources)

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • to clarify, I don't actually call that goal, Eclipse integration sees it and generates the sources. so I was hesitant to point the finger. For the last few years, we haven't had this goal, and occasionally I revisit it to see if we can leverage the autogeneration or are still stuck doing it manually. – CasualT Apr 01 '16 at 22:24
  • I am going to look into that service pattern piece a bit more though...actually...might be able to just set returnRequest...that seems much more obvious after revisiting the documentation. – CasualT Apr 01 '16 at 22:27
  • Eclipse wouldn't run it if it weren't run by your Maven build; remove it from your POM if you don't want to use it. – Thomas Broyer Apr 02 '16 at 13:14
  • So, to say it again, we have had the "generateAsync" goal NOT in our pom for the past several years. However, it would be nice to turn it on to avoid that extra boilerplate. The problem is that the maven plugin is an all-or-nothing approach, where it will generate all the asyncs or none of them (it doesn't care if you've already got them defined manually). – CasualT Apr 04 '16 at 19:00
  • The default behaviour of the plugin is to generate the asyncs all with the void return type. However, I was hoping there was a way to to have it do some with Request return type and some without (based on an annotation or something). Anyhow, the solution was to just turn on the return type of "Request" for all of the generated asyncs, and live with that. – CasualT Apr 04 '16 at 19:00