public void addLibraryDependency(
      MavenArtifact artifact,
      DependencyScope scope,
      MavenModifiableModelsProvider provider,
      MavenProject project) {
    String libraryName = artifact.getLibraryName();

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

    updateUrl(libraryModel, OrderRootType.CLASSES, artifact, null, null, true);
    if (!MavenConstants.SCOPE_SYSTEM.equals(artifact.getScope())) {
      updateUrl(
          libraryModel,
          OrderRootType.SOURCES,
          artifact,
          MavenExtraArtifactType.SOURCES,
          project,
          false);
      updateUrl(
          libraryModel,
          JavadocOrderRootType.getInstance(),
          artifact,
          MavenExtraArtifactType.DOCS,
          project,
          false);
    }

    LibraryOrderEntry e = myRootModel.addLibraryEntry(library);
    e.setScope(scope);
  }
  private void configDependencies() {
    for (MavenArtifact artifact : myMavenProject.getDependencies()) {
      if (!myMavenProject.isSupportedDependency(artifact, SupportedRequestType.FOR_IMPORT))
        continue;

      DependencyScope scope = selectScope(artifact.getScope());
      MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());

      if (depProject != null) {
        if (depProject == myMavenProject) continue;
        boolean isTestJar =
            MavenConstants.TYPE_TEST_JAR.equals(artifact.getType())
                || "tests".equals(artifact.getClassifier());
        myRootModelAdapter.addModuleDependency(
            myMavenProjectToModuleName.get(depProject), scope, isTestJar);

        Element buildHelperCfg =
            depProject.getPluginGoalConfiguration(
                "org.codehaus.mojo", "build-helper-maven-plugin", "attach-artifact");
        if (buildHelperCfg != null) {
          addAttachArtifactDependency(buildHelperCfg, scope, depProject, artifact);
        }
      } else {
        myRootModelAdapter.addLibraryDependency(
            artifact, scope, myModifiableModelsProvider, myMavenProject);
      }
    }

    configSurefirePlugin();
  }