Supergravity, R invariance and spontaneous supersymmetry breaking