The European Union's highest court has ordered Ireland to pay €2.5 million to the European Commission for failing to implement a 2018 directive into Irish law.