docs: private static void addEarToServer(LibertyServer server, String dir, String earName, boolean addEarResources,
                                         String warName, boolean addWarResources, String jarName, boolean addJarResources, String... packageNames) throws Exception {
  
          if (warName == null)
              return;
  
          // If server is already started and app exists no need to add it.
          if (server.isStarted()) {
              String appName = warName.substring(0, warName.indexOf(".war"));
              Set<String> appInstalled = server.getInstalledAppNames(appName);
              LOG.info("addEarToServer : " + appName + " already installed : " + !appInstalled.isEmpty());
  
              if (!appInstalled.isEmpty())
                  return;
          }
  
          JavaArchive jar = null;
          WebArchive war = null;
  
          if (jarName != null) {
  
              LOG.info("addEarToServer : create jar " + jarName + ", jar includes resources : " + addJarResources);
  
              jar = ShrinkWrap.create(JavaArchive.class, jarName);
              if (packageNames != null) {
                  for (String packageName : packageNames) {
                      if (packageName.contains(".jar.")) {
                          jar.addPackage(packageName);
                      }
                  }
              }
              if (addJarResources)
                  ShrinkHelper.addDirectory(jar, "test-applications/" + jarName + "/resources");
          }
  
          war = ShrinkWrap.create(WebArchive.class, warName);
          LOG.info("addEarToServer : create war " + warName + ", war includes resources : " + addWarResources);
          if (packageNames != null) {
              for (String packageName : packageNames) {
                  if (packageName.contains(".war.")) {
                      war.addPackage(packageName);
                  }
              }
          }
          if (jar != null)
              war.addAsLibrary(jar);
          if (addWarResources)
              ShrinkHelper.addDirectory(war, "test-applications/" + warName + "/resources");
  
          if (earName != null) {
              LOG.info("addEarToServer : crteate ear " + earName + ", ear include application/.xml : " + addEarResources);
              EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, earName);
              ear.addAsModule(war);
              if (addEarResources)
                  ear.addAsManifestResource(
                                            new File("test-applications/" + earName + "/resources/META-INF/application.xml"));
  
              //Liberty does not use was.policy but permissions.xml
              File permissionsXML = new File("test-applications/" + earName + "/resources/META-INF/permissions.xml");
              if (permissionsXML.exists()) {
                  ear.addAsManifestResource(permissionsXML);
              }
  
              ShrinkHelper.exportToServer(server, dir, ear);
          } else {
              ShrinkHelper.exportToServer(server, dir, war);
          }
  
      }