Search in sources :

Example 41 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.

the class ResourceCopyingTest method testResourceRoot.

public void testResourceRoot() {
    String file = createFile("res/A.java", "xxx");
    JpsModule m = addModule("m");
    m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaResourceRootType.RESOURCE);
    rebuildAllModules();
    assertOutput(m, fs().file("A.java", "xxx"));
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule)

Example 42 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.

the class CleanArtifactOutputOnRebuildTest method testCleanModuleOutputIfItIsIncludedInArtifact.

public void testCleanModuleOutputIfItIsIncludedInArtifact() {
    String file = createFile("src/A.java", "class A{}");
    JpsModule m = addModule("m", PathUtil.getParentPath(file));
    JpsArtifact a = addArtifact(root().module(m));
    buildArtifacts(a);
    createFileInModuleOutput(m, "b.txt");
    assertOutput(m, fs().file("A.class").file("b.txt"));
    rebuildAllModulesAndArtifacts();
    assertOutput(m, fs().file("A.class"));
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 43 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.

the class ArtifactBuilderTest method testExtractDirectoryFromExcludedJar.

public void testExtractDirectoryFromExcludedJar() throws IOException {
    String jarPath = createFile("dir/lib/j.jar");
    FileUtil.copy(new File(getJUnitJarPath()), new File(jarPath));
    JpsModule module = addModule("m");
    String libDir = PathUtil.getParentPath(jarPath);
    module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(PathUtil.getParentPath(libDir)));
    module.getExcludeRootsList().addUrl(JpsPathUtil.pathToUrl(libDir));
    final JpsArtifact a = addArtifact("a", root().extractedDir(jarPath, "/junit/textui/"));
    buildAll();
    assertOutput(a, fs().file("ResultPrinter.class").file("TestRunner.class"));
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) JarFile(java.util.jar.JarFile) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 44 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.

the class CleanArtifactOutputOnRebuildTest method testDoNotCleanIfContainsArtifactRoot.

public void testDoNotCleanIfContainsArtifactRoot() {
    JpsModule m = addModule("m");
    String resDir = PathUtil.getParentPath(createFile("res/a.txt"));
    m.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(resDir));
    JpsArtifact a = addArtifact(root().dirCopy(resDir));
    a.setOutputPath(resDir);
    buildArtifacts(a);
    assertOutput(a, fs().file("a.txt"));
    createFile("res/b.txt");
    rebuildAllModulesAndArtifacts();
    assertOutput(a, fs().file("a.txt").file("b.txt"));
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 45 with JpsModule

use of org.jetbrains.jps.model.module.JpsModule in project intellij-community by JetBrains.

the class JpsProjectLoader method loadModules.

private void loadModules(Element root, @Nullable final JpsSdkType<?> projectSdkType) {
    Runnable timingLog = TimingLog.startActivity("loading modules");
    Element componentRoot = JDomSerializationUtil.findComponent(root, "ProjectModuleManager");
    if (componentRoot == null)
        return;
    final Set<File> foundFiles = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
    final List<File> moduleFiles = new ArrayList<>();
    for (Element moduleElement : JDOMUtil.getChildren(componentRoot.getChild("modules"), "module")) {
        final String path = moduleElement.getAttributeValue("filepath");
        final File file = new File(path);
        if (foundFiles.add(file) && file.exists()) {
            moduleFiles.add(file);
        } else {
            LOG.info("Module '" + FileUtil.getNameWithoutExtension(file) + "' is skipped: " + file.getAbsolutePath() + " doesn't exist");
        }
    }
    List<JpsModule> modules = loadModules(moduleFiles, projectSdkType, myPathVariables);
    for (JpsModule module : modules) {
        myProject.addModule(module);
    }
    timingLog.run();
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsElement(org.jetbrains.jps.model.JpsElement) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) Element(org.jdom.Element) ArrayList(java.util.ArrayList) File(java.io.File) THashSet(gnu.trove.THashSet)

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