Building GPE: What We Learned


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Building GPE: What We Learned

  1. 1. Building the Google Plugin for Eclipse What We Learned Presented by: Rajeev Dayal Originally Presented by: Miguel Mendez (at Eclipse Day 2009) Google Confidential and Proprietary 1Monday, April 25, 2011 1
  2. 2. Agenda Background Plugin Design Principles Challenges, Solutions, and Lessons GWT = Google Web Toolkit GPE = Google Plugin for Eclipse Google Confidential and Proprietary 2Monday, April 25, 2011 2
  3. 3. Background GPE, GWT, and App Engine Google Confidential and Proprietary 3Monday, April 25, 2011 3
  4. 4. What is the Google Plugin for Eclipse? Collection of Eclipse plugins Assists in the creation of Web Apps that use: • Google Web Toolkit • App Engine for Java Google Confidential and Proprietary 4Monday, April 25, 2011 4
  5. 5. What is the Google Web Toolkit? Writing AJAX apps is hard • JavaScript is a dynamically-typed language • Each browser has its own quirks What if you could write AJAX apps in Java? • great tooling support (Eclipse!) • autocompletion, refactoring • first-class debugging Enter GWT • Debug your web app code in Eclipse while executing against a real browser • Cross-compile your application into stand-alone, optimized JavaScript for each browser • Developers can still get to raw JavaScript via JavaScript Native Interface (JSNI) Google Confidential and Proprietary 5Monday, April 25, 2011 5
  6. 6. What is App Engine? App Engine is a cloud computing platform • write a web app in Java (or Python) and deploy it • lives at <app id> (or a custom domain) We provide the container and services (Platform-as-a-Service) • Hardware connectivity • JVM • Servlet Container • Software services • Automatic scaling Your app is isolated from other running apps • Sandboxing - restrict JVM permissions, whitelist JRE classes • DevAppServer - local development server that emulates the production environment Google Confidential and Proprietary 6Monday, April 25, 2011 6
  7. 7. Plugin Design Principles Google Confidential and Proprietary 7Monday, April 25, 2011 7
  8. 8. Design Principles Stability is paramount Make it easy to get started Reward sophisticated developers Control is happiness Keep things simple Blend naturally into Eclipse Developer’s time is valuable - help them maximize it Minimize plugin magic Google Confidential and Proprietary 8Monday, April 25, 2011 8
  9. 9. Challenges, Solutions, and Lessons Google Confidential and Proprietary 9Monday, April 25, 2011 9
  10. 10. Installation Challenge • Don’t make the user download all of the pieces individually • GPE is ready for use once installation completes • People behind firewalls Solution • Bundle the App Engine and GWT SDKs as plugins • Produce stand-alone archives for people behind firewalls Lessons • P2 garbage collection  don’t solve this by burning the SDK version number into the plugin id :)  make ‘SDK plugins’ non-singletons • GPE has dependencies that are not in the standalone Eclipse distro - producing archives to be placed in ‘archives’ is a bad idea • Optional plugins - P2 is GREEDY Google Confidential and Proprietary 10Monday, April 25, 2011 10
  11. 11. New Web Application Challenge • Quickly create web apps that use GWT and/or App Engine • Use an exploded WAR layout Solution • Create a wizard that generates web apps that are ready-for-launch • Allow users to select which versions of GWT/App Engine to use • Use project natures to indicate what is being used, allow users to add GWT/ App Engine after the fact • Manage SDK jars in the WEB-INF/lib folder Lessons • Not everyone wants sample code generated • Did not make it easy to import GWT/App Engine samples Google Confidential and Proprietary 11Monday, April 25, 2011 11
  12. 12. Run/Debug Web Apps Challenge • Create a simple, customizable launch configuration • Handle possible combinations of GWT & App Engine • App Engine and GWT use different development servers • Maximize transparency - users should be able to see additional program and VM args Solution • Extend Java launch configurations and add some guiding UI • Classpath provider to add source paths needed by GWT • Launch configuration processors - keep program args and VM args in sync with changes in the launch config settings in the UI Google Confidential and Proprietary 12Monday, April 25, 2011 12
  13. 13. Run/Debug Web Apps Lessons • Classpath modifications and reset are imperative • Eclipse’s launch configuration infrastructure is not meant to handle the case of one launch configuration tab affecting another  there’s no consistent ‘model’ for all of the tabs • Be careful when using performApply and updateLaunchConfigurationDialog as a hook point for launch configuration processors  slow launch configuration processors slow down the launch config UI  launch configuration processors that rely on class lookups slow down in proportion to the size of the classpath • What do you do if the user modifies an argument that a launch configuration processor is responsible for? Google Confidential and Proprietary 13Monday, April 25, 2011 13
  14. 14. SDKs Challenge • Plugin should support multiple versions of the App Engine and GWT SDKs • Make it easy to switch versions • Properly configure complex classpaths Solution • Classpath containers, e.g. JRE containers • Classpath dialog and project properties enable trival SDK switching Lessons • Be careful what you do inside of ClasspathContainerInitializers • Default SDK may not have been a great idea • People ignore warnings in the problems view • Classpath containers reduce project portability • Implicit SDKs (especially Maven) Google Confidential and Proprietary 14Monday, April 25, 2011 14
  15. 15. GWT JSNI: Embed JavaScript in Java files Challenge • Embed JavaScript code in Java files • GWT overloads native methods and Java block comment for JSNI • Unfortunately, JSNI delimiters /*-{ }-*/ make JSNI blocks into multi-line comments, and they get formatted as such Solution • Declare a new document partition for JSNI methods • Color JSNI method bodies as JavaScript • Fix up “formatting” performed by auto-format Lessons • Smokescreen pattern • Redoing the formatting works, but alters undo stack • Difference between code path for CTRL-SHIFT-F formatting and auto-format on save Google Confidential and Proprietary 15Monday, April 25, 2011 15
  16. 16. GWT JSNI: Refactoring, Search, and Completion Challenge • JSNI uses JSNI-like signatures that are subject to typos and can invalidated by refactoring • Invisible to Java dependency and Java search Solution • Add completion proposals (based on Java completion proposals) to expand JSNI refs • Add validation (via a compilation participant) to check the validity of JSNI refs • Participate in Java refactoring to update JSNI refs • Participate in Java searches to include refs from JSNI Lessons • Indexing for speed • “This method is not used” for JSNI refs to private methods  @SuppressWarnings(“jsni”) Google Confidential and Proprietary 16Monday, April 25, 2011 16
  17. 17. GWT UiBinder - Validation Challenge • UiBinder files - .ui.xml - are associated with an “owner type” • Validations need to be triggered on the owner type when the .ui.xml file is changed, and vice versa • The .ui.xml file can have references to other Java types - when those types change, the .ui.xml file has to be re-validated Solution • compilation participant looks for Java file changes and triggers a validation on associated .ui.xml files  changes on the owner type  changes in any type referenced by a .ui.xml file • Use a IResourceChangeListener to trigger rebuilds on Java types referenced by a .ui.xml file Google Confidential and Proprietary 17Monday, April 25, 2011 17
  18. 18. GWT UiBinder - Validation Lessons • Be very conservative when triggering rebuilds - workspace can be constantly rebuilding if this is done incorrectly • It would be nice if JDT could model dependencies between resources and Java types Google Confidential and Proprietary 18Monday, April 25, 2011 18
  19. 19. App Engine JRE Whitelist Challenge • Inform developers when they’re using unsupported JRE APIs Solution • compilation participant • Load whitelist out of App Engine SDK • Provide quick-fixes to flag a class as not being used on the server side (a GWT class) Lessons • Caching whitelist can be tricky because the underlying SDK can be changed • Having the IDE change behavior based on the project’s classpath can be confusing Google Confidential and Proprietary 19Monday, April 25, 2011 19
  20. 20. App Engine ORM Challenge • App Engine Datanucleus-based ORM uses bytecode enhancement • Flag enhancement problems before the user runs the app Solution • Drive the Datanucleus enhancer as part of the build • Provide ability to select which classes should be enhanced Lessons • Datanucleus wants to report errors to standard out • Feedback via the console is less than optimal • Want feedback as red squiggly in file • Class file changes are what matter; not source file changes • Do not let exceptions escape from your builders! • Do not perform a refresh(...) in your builder - infinite build time :) Google Confidential and Proprietary 20Monday, April 25, 2011 20
  21. 21. Maven Support Challenge • Have GPE recognize a Maven project that uses GWT and/or App Engine as an actual GWT/App Engine project • Respect the GWT/App Engine SDK that Maven has configured Solution • Integrate with m2Eclipse to apply the App Engine/GWT Nature to a project on the import of a Maven project (and download any needed artifacts) • Prevent users from switching SDKs on a Maven project, and “synthesize” a GWT/App Engine SDK for Maven projects based on the build path Lessons • Maven breaks up the canonical SDK and renames its jars • Build classpath != launch classpath (Maven is VERY specific about this) • Sometimes the jars that you need for launch have not been downloaded from Maven central! Google Confidential and Proprietary 21Monday, April 25, 2011 21
  22. 22. Compilation Participants and ASTs Challenge • Need to perform fine-grained validation on Java files  for UiBinder, RPC, JSNI, App Engine JRE) Solution • Use compilation participants to give you access to the Java AST as the user types (reconcile()), and as a pre-build hook on the Java Builder • Create ASTs from compilation units in buildStarting() Lessons • Compilation participants do not have access to the compile-time AST • Resolving type bindings in an AST takes a long time and takes up lots of memory; proportional to your classpath and source size  use ASTBatchParser to speed things up • compilation participants must complete before the Java Build can complete • penalty for full rebuilds (from a type rename, classpath change) Google Confidential and Proprietary 22Monday, April 25, 2011 22
  23. 23. Other Challenges GWT RPC support • paired interfaces that need to be kept in sync • interfaces do not have a common ancestor type • refactoring is tricky - we need to perform the rename of the paired type after JDT’s real refactoring GWT CSS support • static “extensions” to CSS • need to modify WTP’s parser for the XML editor to understand GWT’s CSS constructs • generated a new CSS tokenizer from .flex rules • formatter would corrupt CSS constructs that it was not aware of; had to replace these with known constructs, allow the formatting to take place, and then put the originals back Google Confidential and Proprietary 23Monday, April 25, 2011 23
  24. 24. Other Challenges The Google Build System • specific rules about how GWT and App Engine projects are built and pull in dependencies • the assumptions that we make about project and SDK structure do not hold • parallels to the problems with Maven (sdks, build classpath != launch classpath) Development Mode View • shows information about active GWT sessions • server information is displayed to the console; console fights with development mode view for focus • which perspective do you contribute to? Deploy to Google • saving credentials - secure storage may prompt you for a password :( • having GWT participate in the compile Google Confidential and Proprietary 24Monday, April 25, 2011 24
  25. 25. Questions ? ? ? ? Google Confidential and Proprietary 25Monday, April 25, 2011 25
  26. 26. Thank You Documentation  Update sites  Eclipse 3.6 (Helios) -  Eclipse 3.5 (Galileo) -  Eclipse 3.4 (Ganymede) - Google Web Toolkit and general GPE Feedback  Group -  Issue Tracker - App Engine Feedback  Group -  Issue Tracker - Google Confidential and Proprietary 26Monday, April 25, 2011 26