Search in sources :

Example 96 with JpsModule

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);
    }
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) Element(org.jdom.Element) ArrayList(java.util.ArrayList) IOException(java.io.IOException) JpsModule(org.jetbrains.jps.model.module.JpsModule) Future(java.util.concurrent.Future) File(java.io.File) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 97 with JpsModule

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());
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule)

Example 98 with JpsModule

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());
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule)

Example 99 with JpsModule

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());
}
Also used : JpsLibraryDependency(org.jetbrains.jps.model.module.JpsLibraryDependency) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsDependencyElement(org.jetbrains.jps.model.module.JpsDependencyElement) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

Example 100 with JpsModule

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);
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule)

Aggregations

JpsModule (org.jetbrains.jps.model.module.JpsModule)128 File (java.io.File)33 NotNull (org.jetbrains.annotations.NotNull)15 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)15 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)14 JpsAndroidModuleExtensionImpl (org.jetbrains.jps.android.model.impl.JpsAndroidModuleExtensionImpl)13 JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)13 THashSet (gnu.trove.THashSet)11 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)11 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)10 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)10 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)10 ArrayList (java.util.ArrayList)9 HashMap (com.intellij.util.containers.HashMap)8 IOException (java.io.IOException)8 TObjectLongHashMap (gnu.trove.TObjectLongHashMap)7 JpsDependencyElement (org.jetbrains.jps.model.module.JpsDependencyElement)7 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)6 Pair (com.intellij.openapi.util.Pair)5 Nullable (org.jetbrains.annotations.Nullable)5