Dinesh has a very detailed description of
How to Build GlassFish.
He shows how to check out the sources, setup the environment, build GlassFish, start up the server,
and run the QuickLook tests (a basic sanity check that runs quickly enough to be used routinely).
The instructions describe how to build a submodule and also how to get the beta-branch code.
Note that some of the
GlassFish components have their sources elsewhere
(like JAXB) and those will have their own build instructions.