How can I build UE4.8 from source?

I think the best way to learn how to write a plugin is to analyze how BlankPlugin looks like (Engine/Plugins/Developer/BlankPlugin).

Or to check how any of plugins or simple modules in Runtime directory looks like (for example the PhysXFormats).

To build engine from source code: Building Unreal Engine from Source | Unreal Engine Documentation