Copying SDM's output to Phonegap's www directory for easier phone development?

90 views
Skip to first unread message

Ali

unread,
Nov 13, 2014, 1:31:20 AM11/13/14
to google-we...@googlegroups.com
There is a way to have a very fast compile -> refresh cycle for phone app development, i.e hitting 'Compile' for SDM, and having the app refresh on your phone.

This can be done through Phonegap's app ( http://app.phonegap.com/ ) which monitors your www folder. Each time you make any changes, they are sent over wifi to your phone, and your app auto refreshes on the phone. 

A similar utility can be written, which monitors SDM's output folder. Each time you do an SDM compile, it syncs the SDM output folder with phonegap's www, which would then trigger a refresh on your phone.

I think this can be very productive, and I'm happy to write this utility. However, I need to know how it would determine where SDM's output directory is located. I.e, can the user find out where the output is being stored, and pass the path as an argument to the directory? If not, the user can just input the codeserver url, and the files can be monitored via an http request, although that would be less efficient.

Please let me know of your thoughts and how to determine SDM's output directory path, or if there's a better way to do what I'm trying to accomplish.

Thanks.

jonl

unread,
Nov 13, 2014, 8:51:30 AM11/13/14
to google-we...@googlegroups.com
Look at the flags of the CodeServer.  You can use flag "-workDir" to specify the directory specifically where output is compiled to.


If you do not use this flag, it outputs to a temporary directory.  The directory is output when the CodeServer is started up.


Since the "CodeServer" serves the code, you could also just talk to it directly, via its api, to download files.  IE instead of pushing the updated code to the phonegap app, if SDM is enabled in the compiled app, it will automatically redirect to the codeserver. You could look at how GWT turns on SuperDevMode with the old bookmarklets and do something similar by injecting javascript into the webpage. 

Ali Akhtar

unread,
Nov 13, 2014, 11:36:23 AM11/13/14
to google-we...@googlegroups.com
Thanks a lot Jonl, that -workDir flag is perfect.

> instead of pushing the updated code to the phonegap app, if SDM is enabled in the compiled app, it will automatically redirect to the codeserver

Right, but if you're developing a native app, you want to see it run as an app without the UI of the browser around it. For that, PhoneGap's app works perfectly. Also, it reloads automatically when files are updated, you don't have to press a reload button.

Ali Akhtar

unread,
Nov 13, 2014, 12:24:14 PM11/13/14
to google-we...@googlegroups.com
Niloc132 on IRC has pointed out an important issue: If you re-compile from the desktop, it will use the desktop's user agent and the permutation specified will be for the desktop. Is there any way to tell GWT to generate a few permutations, for the specified user agents (i.e for desktop & phone both), that way, while the optimizations are off, it will still compile quickly and you could test it on both desktop & phone at the same time.

Jonathon Lamon

unread,
Nov 13, 2014, 12:24:38 PM11/13/14
to google-we...@googlegroups.com
I don't think you understand what I am saying.

When SuperDevMode is enabled, the js file that is created automatically redirects to the CodeServer for all requests. You can use that script, deployed to the app, to automatically redirect to the CodeServer.  I do this with a Cordova application, although I had to make a few modifications to allow us to point to the correct url.

So if you deploy the js that is compiled for running super dev mode, there is no need to download the updates or push them to the app on the device, the js automatically redirects all the requests to CodeServer instead.

Jonathon Lamon
Principle Software Engineer
Perceptronics Solutions Inc.
Tel  703-485-2922
Cell 269-205-4649
www.percsolutions.com

--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/KsvUwfRD4kE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Jonathon Lamon

unread,
Nov 13, 2014, 12:32:03 PM11/13/14
to google-we...@googlegroups.com
you can specify the user.agent in the GWT settings for your module.gwt.xml:


You can also specify <collapse-all-proeprties/> to limit the permutations.


Jonathon Lamon
Principle Software Engineer
Perceptronics Solutions Inc.
Tel  703-485-2922
Cell 269-205-4649
www.percsolutions.com

On Thu, Nov 13, 2014 at 10:24 AM, Ali Akhtar <ali.r...@gmail.com> wrote:
Niloc132 on IRC has pointed out an important issue: If you re-compile from the desktop, it will use the desktop's user agent and the permutation specified will be for the desktop. Is there any way to tell GWT to generate a few permutations, for the specified user agents (i.e for desktop & phone both), that way, while the optimizations are off, it will still compile quickly and you could test it on both desktop & phone at the same time.

--

Ali Akhtar

unread,
Nov 13, 2014, 1:01:39 PM11/13/14
to google-we...@googlegroups.com
If I specify the user-agent through <set property>, then it would only generate one permutation for that user agent.

What I want to do instead is, I want to specify 2-3 user agents, and have SDM generate permutations for all 3 of those user agents with each refresh. 

That way, I can see a refresh for desktop, mobile, and tablet all at once, when i recompile SDM.

Is that possible?

Jonathon Lamon

unread,
Nov 13, 2014, 5:29:08 PM11/13/14
to google-we...@googlegroups.com
You can specify multiple user agents in the user.agent string.

      <set-property name="user.agent" value="ie10,gecko,gecko1_8" />

Also, it depends on what you mean by "desktop, mobile, and tablet".  The "safari" user.agent settings covers Chrome, Safari and most likely any webkit or blink based browser for desktop, mobile and tablet.

Also, consider that "user.agent" in GWT does not necessarily equal the browser user agent.  Each user.agent may support multiple browsers.

Look up com.google.gwt.user.UserAgent.gwt.xml, for possible user.agent values.


Jonathon Lamon
Principle Software Engineer
Perceptronics Solutions Inc.
Tel  703-485-2922
Cell 269-205-4649
www.percsolutions.com

--

Ali Akhtar

unread,
Nov 13, 2014, 6:20:41 PM11/13/14
to google-we...@googlegroups.com
Appreciate your help. 

Here's where I'm at so far:

1) Using the steps outlined at: 


I'm able to run my app on my phone, through Chrome, and if I reload it, that causes it to recompile through SDM and my changes are fetched.

2) However, if I make a phonegapp app, and include a link in it to reload the app, that doesn't cause it to recompile the app on reload, even though the javascript is still being fetched from the SDM codeserver. 

3) By printing the user agent, I've found that the Android WebView (used in the phonegap app) is chrome version 30, while the regular chrome version is 34. I think SDM recompile on refresh only works with Chrome 34+ ? That's the only reason I can think of, for why reloading from the app doesn't trigger a recompile.

As it stands, I'm forced to use chrome on phone to develop the app. If anyone has a better setup, I'd love to know.

Thanks.

Ali Akhtar

unread,
Nov 13, 2014, 7:34:56 PM11/13/14
to google-we...@googlegroups.com
Update: Due to being a moron, I had forgotten to update phonegap's www/index.html file which was causing the issues from my last message. After updating index.html to use the method described at:


Everything now works as expected. When I make any changes, running 'touch index.html` from phonegap/www triggers a reload within Phonegap's developer app, which then triggers an SDM compile, and then the changes can be seen.

Reply all
Reply to author
Forward
0 new messages