private void handleSkinnyWars(final CompileContext context,
                                  final MavenProjectConfiguration projectConfiguration,
                                  MavenModuleResourceConfiguration moduleResourceConfiguration) {
      if (!"ear".equals(moduleResourceConfiguration.modelMap.get("packaging"))) return;
      if (!Boolean.parseBoolean(moduleResourceConfiguration.modelMap.get("build.plugin.maven-ear-plugin.skinnyWars"))) return;

      final String earClasspath = moduleResourceConfiguration.classpath;
      if (earClasspath == null) return;

      final Map<String, String> earClasspathMap = ContainerUtil.map2Map(
        StringUtil.split(earClasspath, " "), s -> {
          final int idx = s.lastIndexOf("/");
          return Pair.create(s.substring(idx == -1 ? 0 : idx + 1), s);
        });

      JpsArtifactUtil.processPackagingElements(myArtifact.getRootElement(), element -> {
        if (!(element instanceof JpsFileCopyPackagingElement)) return true;
        final JpsFileCopyPackagingElement fileCopyPackagingElement = (JpsFileCopyPackagingElement)element;

        final String filePath = fileCopyPackagingElement.getFilePath();
        final File skinnyManifest = new File(filePath);
        if (!"SKINNY_MANIFEST.MF".equals(skinnyManifest.getName())) return true;

        final String skinnyWarModuleName = skinnyManifest.getParentFile().getParentFile().getName();
        final MavenModuleResourceConfiguration warConfiguration = projectConfiguration.moduleConfigurations.get(skinnyWarModuleName);
        if (warConfiguration == null || warConfiguration.classpath == null) return true;

        try {
          final byte[] warManifestData = Base64.getDecoder().decode(warConfiguration.manifest);
          Manifest warManifest = new Manifest(new ByteArrayInputStream(warManifestData));

          List<String> skinnyWarClasspath = new ArrayList<>();
          for (String entry : StringUtil.split(warConfiguration.classpath, " ")) {
            final int idx = entry.lastIndexOf("/");
            final String entryName = entry.substring(idx == -1 ? 0 : idx + 1);
            final String earEntryPath = earClasspathMap.get(entryName);
            skinnyWarClasspath.add(earEntryPath == null ? entry : earEntryPath);
          }

          final Attributes warManifestMainAttributes = warManifest.getMainAttributes();
          warManifestMainAttributes.putValue("Class-Path", StringUtil.join(skinnyWarClasspath, " "));

          File skinnyManifestTargetFile = null;
          FileUtil.createParentDirs(skinnyManifest);
          try (FileOutputStream outputStream = new FileOutputStream(skinnyManifest)) {
            warManifest.write(outputStream);

            if (fileCopyPackagingElement instanceof JpsElementBase) {
              final LinkedList<String> pathParts = new LinkedList<>();
              pathParts.add(fileCopyPackagingElement.getRenamedOutputFileName());

              JpsElementBase parent = ((JpsElementBase<?>)fileCopyPackagingElement).getParent();
              while (parent != null) {
                if (parent instanceof JpsDirectoryPackagingElement) {
                  pathParts.addFirst(((JpsDirectoryPackagingElement)parent).getDirectoryName());
                }
                else if (parent instanceof JpsArtifact) {
                  final String outputPath = ((JpsArtifact)parent).getOutputPath();
                  if (outputPath != null) {
                    pathParts.addFirst(outputPath);
                    skinnyManifestTargetFile = new File(StringUtil.join(pathParts, "/"));
                    break;
                  }
                }
                parent = parent.getParent();
              }
            }
          }

          if (skinnyManifestTargetFile != null) {
            FileUtil.createParentDirs(skinnyManifestTargetFile);
            FileUtil.copy(skinnyManifest, skinnyManifestTargetFile);
          }

          FSOperations.markDirtyIfNotDeleted(context, CompilationRound.NEXT, skinnyManifest);
          FSOperations.markDirtyIfNotDeleted(context, CompilationRound.NEXT, skinnyManifestTargetFile);
        }
        catch (IOException e) {
          LOG.debug(e);
        }

        return true;
      });
    }
private void handleSkinnyWars(final CompileContext context,
                                  final MavenProjectConfiguration projectConfiguration,
                                  MavenModuleResourceConfiguration moduleResourceConfiguration)