PluginV1 vs PluginV2 - what's the difference?

Hi everyone :wave:

This is probably a very primitive question - but I haven’t been able to find any piece of documentation that explains the difference between the two different plugin implementations - PluginV1 & PluginV2. The official documentation on local plugins seem to be very limited with snapcraft.BasePlugin being the base. The only way anyone seems to be able to understand them is by looking at some of the existing plugins on the snapcraft repository.

My overall question boils down to the following two -

  1. What’s the exact difference between these two? In other words, why two?
  2. When to use which base?

As a bonus - anything else that I may be missing here. Really appreciate the time here! Thanks in advance :slight_smile:

There’s a decent explaination of the V2 plugins in the link. The most important bit is generally the fact a V2 plugin only focuses on the build stage, meaning it has a clearly defined role with less responsibilies, letting snapcraft itself handle the other stages.

I don’t think you have a choice of which plugin base to use, core20 is V2 only, core18 and core are V1 only, but I could be wrong. If you meant which base as in core18 vs core20, I’d generally say pick the newest available as far as reasonably possible, benefitting from newer packages and compiler toolchains & etc; but it’s not always greener on the newer side; there’s less V2 plugins than V1 plugins right now for instance, so people might prefer Core18 with V1 purely because Core20 might not actually have what they need yet.