コード例 #1
0
 @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);
     }
   }
 }
コード例 #2
0
  @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);
  }