@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 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); }
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()); } } }
@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); }