Moved the Maven publication logic so that it is only triggered when the java plugin is included.