As a developer, one drawback of using Google Web Toolkit (GWT) for the oVirt Administration Portal (aka webadmin) is that the GWT compile process takes an exceptionally long time. If you make a change in some code and rebuild the ovirt-engine project using make install-dev ...
, you’ll be waiting several minutes to test your change. In practice, such a long delay in the usual code-compile-refresh-test cycle would be unbearable.
Luckily, we can use GWT Super Dev Mode (“SDM”) to start up a quick refresh-capable instance of the application. With SDM running, you can make a change in GWT and test the refreshed change within seconds.
If you want to step through code and use the Chrome debugger, oVirt and SDM don’t work well together for debugging due to the oVirt Administration Portal’s code and source map size. Therefore, below we demonstrate how to disable source maps.
Demo (40 seconds)
Steps
-
Open a terminal, build the engine normally, and start it.
make clean install-dev PREFIX=$HOME/ovirt-engine DEV_EXTRA_BUILD_FLAGS_GWT_DEFAULTS="-Dgwt.cssResourceStyle=pretty -Dgwt.userAgent=safari" BUILD_UT=0 DEV_EXTRA_BUILD_FLAGS="-Dgwt.compiler.localWorkers=1" ... $HOME/ovirt-engine/share/ovirt-engine/services/ovirt-engine/ovirt-engine.py start
-
In a second terminal, run:
Chrome:
make gwt-debug DEV_BUILD_GWT_SUPER_DEV_MODE=1 DEV_EXTRA_BUILD_FLAGS_GWT_DEFAULTS="-Dgwt.userAgent=safari"
or
Firefox:
make gwt-debug DEV_BUILD_GWT_SUPER_DEV_MODE=1 DEV_EXTRA_BUILD_FLAGS_GWT_DEFAULTS="-Dgwt.userAgent=gecko1_8"
Wait about two minutes until “code server running at http://<>:9876/” displays, and then the GWT Dev Mode app will open.
-
Open your browser and go to http://localhost:9876/ *You must use localhost. The procedure breaks with IPs.
Now you’ll see two buttons, Dev Mode On and Dev Mode Off.
Drag those buttons to the browser bookmark bar, as it says on that page.
-
Ignore the link under the two buttons. Instead, open another browser window and enter http://localhost:8080 in the address bar to go to webadmin.
-
Log in and navigate to the Administration Portal.
-
[Chrome only] Press F12 and click the hamburger menu, followed by Settings. Disable both JavaScript and CSS source maps. The Administration Portal is too large and the source maps crash Chrome.
-
Click Dev Mode On
-
Drag the Compile button to your bookmarks bar
-
Click Compile
The first compilation is slow, taking up to two minutes.
-
Make a change to the GWT code. Here I am creating a new “About” dialog box that has an image as a background. I will tweak the font properties of the dialog’s Close button to demonstrate the refresh.
Before:
Change:
Let’s test.
-
Click Compile. Make sure it says “On”. If it doesn’t, did you use localhost above?
In the second terminal, you will see:
Link succeeded [INFO] Linking succeeded -- 3.654s [INFO] 7.537s total -- Compile completed
The browser should refresh, and the app will now display the change.