code: public static void packageWarsToEar(LibertyServer server, String dir, String earName, boolean addEarResources, String... warFiles) throws Exception {
          String baseDir = DIR_PUBLISH + server.getServerName() + "/" + dir + "/";
          EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, earName);
          if (addEarResources) {
  
              ShrinkHelper.addDirectory(ear, "test-applications/" + earName + "/resources");
  
          }
          for (String warFile : warFiles) {
              WebArchive war = ShrinkWrap.createFromZipFile(WebArchive.class, new File(baseDir + warFile));
              ear.addAsModule(war);
          }
          ShrinkHelper.exportArtifact(ear, DIR_PUBLISH + server.getServerName() + "/" + dir, true, true);
      }
docs: /*
  Helper method to create a ear and placed it to the specified directory which is relative from /publish/servers/ directory.