use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class JpsProjectLoader method loadModules.
@NotNull
public static List<JpsModule> loadModules(@NotNull List<File> moduleFiles, @Nullable final JpsSdkType<?> projectSdkType, @NotNull final Map<String, String> pathVariables) {
List<JpsModule> modules = new ArrayList<>();
List<Future<Pair<File, Element>>> futureModuleFilesContents = new ArrayList<>();
for (final File file : moduleFiles) {
futureModuleFilesContents.add(ourThreadPool.submit(() -> {
final JpsMacroExpander expander = createModuleMacroExpander(pathVariables, file);
final Element moduleRoot = loadRootElement(file, expander);
return Pair.create(file, moduleRoot);
}));
}
try {
final List<String> classpathDirs = new ArrayList<>();
for (Future<Pair<File, Element>> moduleFile : futureModuleFilesContents) {
final String classpathDir = moduleFile.get().getSecond().getAttributeValue(CLASSPATH_DIR_ATTRIBUTE);
if (classpathDir != null) {
classpathDirs.add(classpathDir);
}
}
List<Future<JpsModule>> futures = new ArrayList<>();
for (final Future<Pair<File, Element>> futureModuleFile : futureModuleFilesContents) {
final Pair<File, Element> moduleFile = futureModuleFile.get();
futures.add(ourThreadPool.submit(() -> loadModule(moduleFile.getFirst(), moduleFile.getSecond(), classpathDirs, projectSdkType, pathVariables)));
}
for (Future<JpsModule> future : futures) {
JpsModule module = future.get();
if (module != null) {
modules.add(module);
}
}
return modules;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class JpsDependenciesEnumeratorTest method testModuleDependency.
public void testModuleDependency() throws Exception {
final JpsModule dep = addModule("dep");
final String depSrcRoot = addSourceRoot(dep, false);
final String depTestRoot = addSourceRoot(dep, true);
final String depOutput = setModuleOutput(dep, false);
final String depTestOutput = setModuleOutput(dep, true);
JpsModuleRootModificationUtil.addDependency(dep, createJDomLibrary(), JpsJavaDependencyScope.COMPILE, true);
JpsModuleRootModificationUtil.addDependency(myModule, dep, JpsJavaDependencyScope.COMPILE, true);
final String srcRoot = addSourceRoot(myModule, false);
final String testRoot = addSourceRoot(myModule, true);
final String output = setModuleOutput(myModule, false);
final String testOutput = setModuleOutput(myModule, true);
assertClassRoots(dependencies(myModule).withoutSdk(), testOutput, output, depTestOutput, depOutput);
assertClassRoots(dependencies(myModule).withoutSdk().recursively(), testOutput, output, depTestOutput, depOutput, getJDomJar());
assertSourceRoots(dependencies(myModule), srcRoot, testRoot, depSrcRoot, depTestRoot);
assertSourceRoots(dependencies(myModule).recursively(), srcRoot, testRoot, depSrcRoot, depTestRoot, getJDomSources());
assertClassRoots(dependencies(myModule).withoutSdk().withoutModuleSourceEntries().recursively(), getJDomJar());
assertSourceRoots(dependencies(myModule).withoutSdk().withoutModuleSourceEntries().recursively(), getJDomSources());
assertEnumeratorRoots(dependencies(myModule).withoutSdk().withoutModuleSourceEntries().recursively().classes(), getJDomJar());
assertEnumeratorRoots(dependencies(myModule).withoutSdk().withoutModuleSourceEntries().recursively().sources(), getJDomSources());
assertEnumeratorRoots(dependencies(myModule).withoutSdk().recursively().classes().withoutSelfModuleOutput(), output, depTestOutput, depOutput, getJDomJar());
assertEnumeratorRoots(dependencies(myModule).productionOnly().withoutSdk().recursively().classes().withoutSelfModuleOutput(), depOutput, getJDomJar());
assertClassRoots(dependencies(myModule).withoutSdk().withoutDepModules().withoutModuleSourceEntries().recursively(), getJDomJar());
assertEnumeratorRoots(dependencies(myModule).productionOnly().withoutSdk().withoutDepModules().withoutModuleSourceEntries().recursively().classes(), getJDomJar());
assertClassRoots(dependencies(myModule).withoutSdk().withoutDepModules().withoutModuleSourceEntries());
assertEnumeratorRoots(dependencies(myModule).productionOnly().withoutModuleSourceEntries().withoutSdk().withoutDepModules().classes());
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class JpsDependenciesEnumeratorTest method testNotExportedLibrary.
public void testNotExportedLibrary() throws Exception {
final JpsModule dep = addModule("dep");
JpsModuleRootModificationUtil.addDependency(dep, createJDomLibrary(), JpsJavaDependencyScope.COMPILE, false);
JpsModuleRootModificationUtil.addDependency(myModule, createAsmLibrary(), JpsJavaDependencyScope.COMPILE, false);
JpsModuleRootModificationUtil.addDependency(myModule, dep, JpsJavaDependencyScope.COMPILE, false);
assertClassRoots(dependencies(myModule).withoutSdk(), getAsmJar());
assertClassRoots(dependencies(myModule).withoutSdk().recursively(), getAsmJar(), getJDomJar());
assertClassRoots(dependencies(myModule).withoutSdk().recursivelyExportedOnly(), getAsmJar());
assertClassRoots(dependencies(myModule).withoutSdk().exportedOnly().recursively());
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class JpsJavaExtensionTest method testDependency.
public void testDependency() {
final JpsModel model = myModel.createModifiableModel(new TestJpsEventDispatcher());
final JpsModule module = model.getProject().addModule("m", JpsJavaModuleType.INSTANCE);
final JpsLibrary library = model.getProject().addLibrary("l", JpsJavaLibraryType.INSTANCE);
final JpsLibraryDependency dependency = module.getDependenciesList().addLibraryDependency(library);
getJavaService().getOrCreateDependencyExtension(dependency).setScope(JpsJavaDependencyScope.TEST);
getJavaService().getOrCreateDependencyExtension(dependency).setExported(true);
model.commit();
List<JpsDependencyElement> dependencies = assertOneElement(myProject.getModules()).getDependenciesList().getDependencies();
assertEquals(2, dependencies.size());
final JpsDependencyElement dep = dependencies.get(1);
final JpsJavaDependencyExtension extension = getJavaService().getDependencyExtension(dep);
assertNotNull(extension);
assertTrue(extension.isExported());
assertSame(JpsJavaDependencyScope.TEST, extension.getScope());
}
use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.
the class JpsGantProjectBuilder method buildModules.
public void buildModules(List<JpsModule> modules) {
Set<String> names = new LinkedHashSet<>();
info("Collecting dependencies for " + modules.size() + " modules");
for (JpsModule module : modules) {
Set<String> dependencies = getModuleDependencies(module, false);
for (String dependency : dependencies) {
if (names.add(dependency)) {
info(" adding " + dependency + " required for " + module.getName());
}
}
}
runBuild(names, false, false);
}
Aggregations