You always build ships fresh. When defending in battle, the attacker cannot collect raid dice if you have a fresh defending starport.