26
Google Confidential and Proprietary 1 Building the Google Plugin for Eclipse What We Learned Presented by: Rajeev Dayal Originally Presented by: Miguel Mendez (at Eclipse Day 2009) 1 Monday, April 25, 2011

Building GPE: What We Learned

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Building GPE: What We Learned

Google Confidential and Proprietary 1

Building the Google Plugin for EclipseWhat We Learned

Presented by:

Rajeev Dayal

Originally Presented by:

Miguel Mendez (at Eclipse Day 2009)

1Monday, April 25, 2011

Page 2: Building GPE: What We Learned

Google Confidential and Proprietary

Agenda

Background

Plugin Design Principles

Challenges, Solutions, and Lessons

2

GWT = Google Web Toolkit

GPE = Google Plugin for Eclipse

2Monday, April 25, 2011

Page 3: Building GPE: What We Learned

Google Confidential and Proprietary

BackgroundGPE, GWT, and App Engine

3

3Monday, April 25, 2011

Page 4: Building GPE: What We Learned

Google Confidential and Proprietary

What is the Google Plugin for Eclipse?

4

Collection of Eclipse plugins

Assists in the creation of Web Apps that use:• Google Web Toolkit

• App Engine for Java

4Monday, April 25, 2011

Page 5: Building GPE: What We Learned

Google Confidential and Proprietary

What is the Google Web Toolkit?

5

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)

5Monday, April 25, 2011

Page 6: Building GPE: What We Learned

Google Confidential and Proprietary

What is App Engine?

6

App Engine is a cloud computing platform• write a web app in Java (or Python) and deploy it

• lives at <app id>.appspot.com (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

6Monday, April 25, 2011

Page 7: Building GPE: What We Learned

Google Confidential and Proprietary

Plugin Design Principles

7

7Monday, April 25, 2011

Page 8: Building GPE: What We Learned

Google Confidential and Proprietary

Design Principles

8

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

8Monday, April 25, 2011

Page 9: Building GPE: What We Learned

Google Confidential and Proprietary 9

Challenges, Solutions, and Lessons

9Monday, April 25, 2011

Page 10: Building GPE: What We Learned

Google Confidential and Proprietary

Installation

10

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

10Monday, April 25, 2011

Page 11: Building GPE: What We Learned

Google Confidential and Proprietary

New Web Application

11

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

11Monday, April 25, 2011

Page 12: Building GPE: What We Learned

Google Confidential and Proprietary

Run/Debug Web Apps

12

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

12Monday, April 25, 2011

Page 13: Building GPE: What We Learned

Google Confidential and Proprietary

Run/Debug Web Apps

13

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?

13Monday, April 25, 2011

Page 14: Building GPE: What We Learned

Google Confidential and Proprietary

SDKs

14

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)

14Monday, April 25, 2011

Page 15: Building GPE: What We Learned

Google Confidential and Proprietary

GWT JSNI: Embed JavaScript in Java files

15

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

15Monday, April 25, 2011

Page 16: Building GPE: What We Learned

Google Confidential and Proprietary

GWT JSNI: Refactoring, Search, and Completion

16

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”)

16Monday, April 25, 2011

Page 17: Building GPE: What We Learned

Google Confidential and Proprietary

GWT UiBinder - Validation

17

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

17Monday, April 25, 2011

Page 18: Building GPE: What We Learned

Google Confidential and Proprietary

GWT UiBinder - Validation

18

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

18Monday, April 25, 2011

Page 19: Building GPE: What We Learned

Google Confidential and Proprietary

App Engine JRE Whitelist

19

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

19Monday, April 25, 2011

Page 20: Building GPE: What We Learned

Google Confidential and Proprietary

App Engine ORM

20

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 :)

20Monday, April 25, 2011

Page 21: Building GPE: What We Learned

Google Confidential and Proprietary

Maven Support

21

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!

21Monday, April 25, 2011

Page 22: Building GPE: What We Learned

Google Confidential and Proprietary

Compilation Participants and ASTs

22

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)

22Monday, April 25, 2011

Page 23: Building GPE: What We Learned

Google Confidential and Proprietary

Other Challenges

23

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

23Monday, April 25, 2011

Page 24: Building GPE: What We Learned

Google Confidential and Proprietary

Other Challenges

24

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

24Monday, April 25, 2011

Page 25: Building GPE: What We Learned

Google Confidential and Proprietary

Questions

?25

?

?

?

25Monday, April 25, 2011

Page 26: Building GPE: What We Learned

Google Confidential and Proprietary

Thank You

26

Documentation http://code.google.com/eclipse

Update sites Eclipse 3.6 (Helios) - http://dl.google.com/eclipse/plugin/3.6 Eclipse 3.5 (Galileo) - http://dl.google.com/eclipse/plugin/3.5 Eclipse 3.4 (Ganymede) - http://dl.google.com/eclipse/plugin/3.4

Google Web Toolkit and general GPE Feedback Group - http://groups.google.com/group/Google-Web-Toolkit Issue Tracker - http://code.google.com/p/google-web-toolkit/issues

App Engine Feedback Group - http://groups.google.com/group/google-appengine-java Issue Tracker - http://code.google.com/p/googleappengine/issues

26Monday, April 25, 2011