@Override
 protected void addJUnitDefaultLib(
     JpsModule rootModel, String junitName, ExpandMacroToPathMap macroMap) {
   final String ideaHome =
       macroMap.substitute("$APPLICATION_HOME_DIR$", SystemInfo.isFileSystemCaseSensitive);
   final FilenameFilter junitFilter =
       new FilenameFilter() {
         @Override
         public boolean accept(File dir, String name) {
           return name.startsWith("junit");
         }
       };
   File[] junitJars = new File(ideaHome, "lib").listFiles(junitFilter);
   if (junitJars == null || junitJars.length == 0) {
     junitJars = new File(new File(ideaHome, "community"), "lib").listFiles(junitFilter);
   }
   if (junitJars != null && junitJars.length > 0) {
     final boolean isJUnit4 = junitName.contains("4");
     File junitJar = null;
     for (File jar : junitJars) {
       final boolean isCurrentJarV4 = jar.getName().contains("4");
       if (isCurrentJarV4 && isJUnit4 || !isCurrentJarV4 && !isJUnit4) {
         junitJar = jar;
         break;
       }
     }
     if (junitJar != null) {
       final JpsLibrary jpsLibrary =
           rootModel.addModuleLibrary(junitName, JpsJavaLibraryType.INSTANCE);
       jpsLibrary.addRoot(pathToUrl(junitJar.getPath()), JpsOrderRootType.COMPILED);
       final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
       dependenciesList.addLibraryDependency(jpsLibrary);
     }
   }
 }
 @Override
 protected void addNamedLibrary(
     JpsModule rootModel,
     Collection<String> unknownLibraries,
     boolean exported,
     String name,
     boolean applicationLevel) {
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         "loading "
             + rootModel.getName()
             + ": adding "
             + (applicationLevel ? "application" : "project")
             + " library '"
             + name
             + "'");
   }
   JpsElementFactory factory = JpsElementFactory.getInstance();
   JpsLibraryReference libraryReference;
   final String level = myLibLevels.get(name);
   libraryReference =
       level != null
           ? factory.createLibraryReference(
               name, JpsLibraryTableSerializer.createLibraryTableReference(level))
           : factory.createLibraryReference(name, factory.createGlobalReference());
   final JpsLibraryDependency dependency =
       rootModel.getDependenciesList().addLibraryDependency(libraryReference);
   setLibraryEntryExported(dependency, exported);
 }
 @Override
 protected void setUpModuleJdk(
     JpsModule rootModel,
     Collection<String> unknownJdks,
     EclipseModuleManager eclipseModuleManager,
     String jdkName) {
   if (LOG.isDebugEnabled()) {
     LOG.debug("loading " + rootModel.getName() + ": set module jdk " + jdkName);
   }
   rootModel.getDependenciesList().addSdkDependency(JpsJavaSdkType.INSTANCE);
 }
 public void readClasspath(
     JpsModule model,
     final String testPattern,
     Element classpathElement,
     JpsMacroExpander expander)
     throws IOException {
   LOG.debug("start loading classpath for " + model.getName());
   final HashSet<String> libs = new HashSet<String>();
   for (Object o : classpathElement.getChildren(EclipseXml.CLASSPATHENTRY_TAG)) {
     try {
       readClasspathEntry(
           model,
           new ArrayList<String>(),
           new ArrayList<String>(),
           new HashSet<String>(),
           testPattern,
           (Element) o,
           0,
           null,
           expander.getExpandMacroMap(),
           libs);
     } catch (ConversionException e) {
       throw new IOException(e);
     }
   }
   boolean foundSdkDependency = false;
   JpsDependenciesList dependenciesList = model.getDependenciesList();
   for (JpsDependencyElement element : dependenciesList.getDependencies()) {
     if (element instanceof JpsSdkDependency) {
       foundSdkDependency = true;
       break;
     }
   }
   if (!foundSdkDependency) {
     dependenciesList.addSdkDependency(JpsJavaSdkType.INSTANCE);
   }
   if (LOG.isDebugEnabled()) {
     String name = model.getName();
     LOG.debug(
         "finished loading classpath for "
             + name
             + " ("
             + dependenciesList.getDependencies().size()
             + " items):");
     for (JpsDependencyElement element : dependenciesList.getDependencies()) {
       LOG.debug(" [" + name + "]:" + element.toString());
     }
   }
 }
  public void setupOutput(JpsModule rootModel, final String path) {
    final JpsJavaModuleExtension extension = getService().getOrCreateModuleExtension(rootModel);
    String outputUrl = pathToUrl(path);
    extension.setOutputUrl(outputUrl);
    extension.setTestOutputUrl(outputUrl);
    // extension.setInheritOutput(false);

    rootModel.getDependenciesList().addModuleSourceDependency();
  }
 @Override
 protected void addInvalidModuleEntry(JpsModule rootModel, boolean exported, String moduleName) {
   final JpsElementFactory elementFactory = JpsElementFactory.getInstance();
   final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
   final JpsModuleDependency dependency =
       dependenciesList.addModuleDependency(elementFactory.createModuleReference(moduleName));
   final JpsJavaDependencyExtension extension =
       getService().getOrCreateDependencyExtension(dependency);
   extension.setExported(exported);
 }
  @Override
  protected void addModuleLibrary(
      JpsModule rootModel,
      Element element,
      boolean exported,
      String libName,
      String url,
      String srcUrl,
      ExpandMacroToPathMap macroMap) {
    final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(libName, JpsJavaLibraryType.INSTANCE);
    final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
    final JpsLibraryDependency dependency = dependenciesList.addLibraryDependency(jpsLibrary);
    url = StringUtil.trimStart(url, "file://");
    final String linked = expandLinkedResourcesPath(url, macroMap);
    if (linked != null) {
      url = pathToUrl(linked);
    } else {
      url = expandEclipsePath2Url(rootModel, url);
    }
    LOG.debug("loading " + rootModel.getName() + ": adding module library " + libName + ": " + url);
    jpsLibrary.addRoot(url, JpsOrderRootType.COMPILED);

    setLibraryEntryExported(dependency, exported);
  }
 @Override
 protected void addSourceFolderToCurrentContentRoot(
     JpsModule rootModel, String srcUrl, boolean testFolder) {
   rootModel.addSourceRoot(
       srcUrl, testFolder ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE);
 }