The BV formalism in classical and quantum field theories