Exemplo n.º 1
0
  @Override
  public Dependency addDependency(@NotNull SModuleReference moduleRef, boolean reexport) {
    // we do not add a dependency into solution, we add dependency to idea module instead
    ModifiableRootModel modifiableModel =
        ModuleRootManager.getInstance(myModule).getModifiableModel();

    SModule sModule = moduleRef.resolve(MPSModuleRepository.getInstance()); // FIXME module repo

    if (sModule instanceof SolutionIdea) {
      // we add dependency between idea modules
      Module otherIdeaModule = ((SolutionIdea) sModule).getIdeaModule();
      modifiableModel.addModuleOrderEntry(otherIdeaModule);
    } else {
      ModuleRuntimeLibrariesImporter.importForUsedModules(
          myModule, Collections.singleton(moduleRef), modifiableModel);
    }
    modifiableModel.commit();
    return null;
  }
  public void addModuleDependency(
      @NotNull String moduleName, @NotNull DependencyScope scope, boolean testJar) {
    Module m = findModuleByName(moduleName);

    ModuleOrderEntry e;
    if (m != null) {
      e = myRootModel.addModuleOrderEntry(m);
    } else {
      AccessToken accessToken = ReadAction.start();
      try {
        e = myRootModel.addInvalidModuleEntry(moduleName);
      } finally {
        accessToken.finish();
      }
    }

    e.setScope(scope);
    if (testJar) {
      ((ModuleOrderEntryImpl) e).setProductionOnTestDependency(true);
    }
  }