Robert Lewandowski will join Bayern Munich in the summer after agreeing a five-year deal with the Bundesliga giants.