private void addAttachArtifactDependency(
      @NotNull Element buildHelperCfg,
      @NotNull DependencyScope scope,
      @NotNull MavenProject mavenProject,
      @NotNull MavenArtifact artifact) {
    Library.ModifiableModel libraryModel = null;

    for (Element artifactsElement : (List<Element>) buildHelperCfg.getChildren("artifacts")) {
      for (Element artifactElement : (List<Element>) artifactsElement.getChildren("artifact")) {
        String typeString = artifactElement.getChildTextTrim("type");
        if (typeString != null && !typeString.equals("jar")) continue;

        OrderRootType rootType = OrderRootType.CLASSES;

        String classifier = artifactElement.getChildTextTrim("classifier");
        if ("sources".equals(classifier)) {
          rootType = OrderRootType.SOURCES;
        } else if ("javadoc".equals(classifier)) {
          rootType = JavadocOrderRootType.getInstance();
        }

        String filePath = artifactElement.getChildTextTrim("file");
        if (StringUtil.isEmpty(filePath)) continue;

        VirtualFile file = VfsUtil.findRelativeFile(filePath, mavenProject.getDirectoryFile());
        if (file == null) continue;

        file = JarFileSystem.getInstance().getJarRootForLocalFile(file);
        if (file == null) continue;

        if (libraryModel == null) {
          String libraryName = artifact.getLibraryName();
          assert libraryName.startsWith(MavenArtifact.MAVEN_LIB_PREFIX);
          libraryName =
              MavenArtifact.MAVEN_LIB_PREFIX
                  + "ATTACHED-JAR: "
                  + libraryName.substring(MavenArtifact.MAVEN_LIB_PREFIX.length());

          Library library = myModifiableModelsProvider.getLibraryByName(libraryName);
          if (library == null) {
            library = myModifiableModelsProvider.createLibrary(libraryName);
          }
          libraryModel = myModifiableModelsProvider.getLibraryModel(library);

          LibraryOrderEntry entry = myRootModelAdapter.getRootModel().addLibraryEntry(library);
          entry.setScope(scope);
        }

        libraryModel.addRoot(file, rootType);
      }
    }
  }
  private void configEncoding() {
    if (Boolean.parseBoolean(System.getProperty("maven.disable.encode.import"))) return;

    String encoding = myMavenProject.getEncoding();
    if (encoding != null) {
      try {
        EncodingProjectManager.getInstance(myModule.getProject())
            .setEncoding(myMavenProject.getDirectoryFile(), Charset.forName(encoding));
      } catch (UnsupportedCharsetException ignored) {
        /**/
      } catch (IllegalCharsetNameException ignored) {
        /**/
      }
    }
  }
  private void excludeFromCompilationArchetypeResources() {
    VirtualFile directoryFile = myMavenProject.getDirectoryFile();

    VirtualFile archetypeResourcesDir =
        VfsUtil.findRelativeFile(directoryFile, "src", "main", "resources", "archetype-resources");

    if (archetypeResourcesDir != null) {
      Project project = myModule.getProject();

      CompilerConfigurationImpl compilerConfiguration =
          (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);

      if (!compilerConfiguration.isExcludedFromCompilation(archetypeResourcesDir)) {
        ExcludedEntriesConfiguration cfg = compilerConfiguration.getExcludedEntriesConfiguration();

        cfg.addExcludeEntryDescription(
            new ExcludeEntryDescription(archetypeResourcesDir, true, false, project));
      }
    }
  }