Search in sources :

Example 51 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class ArtifactBuilderOverwriteTest method testOverwriteArchives.

public void testOverwriteArchives() {
    final String aFile = createFile("aaa.txt", "a");
    final String bFile = createFile("bbb.txt", "b");
    final JpsArtifact a = addArtifact(root().archive("x.jar").fileCopy(aFile).end().archive("x.jar").fileCopy(bFile));
    buildAll();
    assertOutput(a, fs().archive("x.jar").file("aaa.txt", "a"));
    buildAllAndAssertUpToDate();
    change(aFile, "a2");
    buildAll();
    assertDeletedAndCopied("out/artifacts/a/x.jar", "aaa.txt");
    assertOutput(a, fs().archive("x.jar").file("aaa.txt", "a2"));
    buildAllAndAssertUpToDate();
    change(bFile, "b2");
    buildAllAndAssertUpToDate();
    delete(bFile);
    buildAllAndAssertUpToDate();
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 52 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class ArtifactBuilderOverwriteTest method testDeleteOverwritingFiles.

public void testDeleteOverwritingFiles() {
    final String firstFile = createFile("d1/xxx.txt", "1");
    final String secondFile = createFile("d2/xxx.txt", "2");
    final JpsArtifact a = addArtifact("a", root().dir("ddd").dirCopy(PathUtil.getParentPath(firstFile)).parentDirCopy(secondFile).fileCopy(createFile("y.txt")));
    buildAll();
    assertOutput(a, fs().dir("ddd").file("xxx.txt", "1").file("y.txt"));
    delete(firstFile);
    buildAll();
    assertDeletedAndCopied("out/artifacts/a/ddd/xxx.txt", "d2/xxx.txt");
    assertOutput(a, fs().dir("ddd").file("xxx.txt", "2").file("y.txt"));
    buildAllAndAssertUpToDate();
    delete(secondFile);
    buildAll();
    assertDeleted("out/artifacts/a/ddd/xxx.txt");
    assertOutput(a, fs().dir("ddd").file("y.txt"));
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 53 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class ArtifactBuilderOverwriteTest method testUpdateManifest.

public void testUpdateManifest() {
    final String manifestText1 = "Manifest-Version: 1.0\r\nMain-Class: A\r\n\r\n";
    final String manifest = createFile("d/MANIFEST.MF", manifestText1);
    final JpsArtifact a = addArtifact("a", root().archive("a.jar").dir("META-INF").parentDirCopy(manifest).fileCopy(createFile("a.txt")));
    buildAll();
    assertOutput(a, fs().archive("a.jar").dir("META-INF").file("MANIFEST.MF", manifestText1).file("a.txt"));
    final String manifestText2 = "Manifest-Version: 1.0\r\nMain-Class: B\r\n\r\n";
    change(manifest, manifestText2);
    buildAll();
    assertDeletedAndCopied("out/artifacts/a/a.jar", "d/MANIFEST.MF", "a.txt");
    assertOutput(a, fs().archive("a.jar").dir("META-INF").file("MANIFEST.MF", manifestText2).file("a.txt"));
    buildAllAndAssertUpToDate();
    delete(manifest);
    buildAll();
    assertDeletedAndCopied("out/artifacts/a/a.jar", "a.txt");
    assertOutput(a, fs().archive("a.jar").dir("META-INF").file("a.txt"));
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 54 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class IncrementalArtifactBuildingTest method testRemoveDeletedFile.

public void testRemoveDeletedFile() {
    String file1 = createFile("dir/a.txt");
    createFile("dir/b.txt");
    final JpsArtifact a = addArtifact("a", root().parentDirCopy(file1));
    buildAll();
    assertOutput(a, fs().file("a.txt").file("b.txt"));
    delete(file1);
    buildAll();
    assertDeleted("out/artifacts/a/a.txt");
    assertOutput(a, fs().file("b.txt"));
    buildAllAndAssertUpToDate();
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 55 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class IncrementalArtifactBuildingTest method testMoveClassFromOneModuleToAnother.

public void testMoveClassFromOneModuleToAnother() {
    String file = createFile("src1/A.java", "class A{}");
    JpsModule m1 = addModule("m1", PathUtil.getParentPath(file));
    JpsModule m2 = addModule("m2", PathUtil.getParentPath(createFile("src2/B.java", "class B{}")));
    JpsArtifact a = addArtifact(root().module(m1).module(m2));
    buildAll();
    assertOutput(a, fs().file("A.class").file("B.class"));
    delete(file);
    createFile("src2/A.java", "class A{}");
    buildAll();
    assertOutput(a, fs().file("A.class").file("B.class"));
    assertDeletedAndCopied(new String[] { "out/artifacts/a/A.class", "out/production/m1/A.class" }, "out/production/m2/A.class");
    buildAllAndAssertUpToDate();
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Aggregations

JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)85 File (java.io.File)10 JpsModule (org.jetbrains.jps.model.module.JpsModule)10 JarFile (java.util.jar.JarFile)4 ZipFile (java.util.zip.ZipFile)4 IOException (java.io.IOException)3 NotNull (org.jetbrains.annotations.NotNull)3 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)3 JpsCompositePackagingElement (org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement)3 THashSet (gnu.trove.THashSet)2 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)2 JpsElement (org.jetbrains.jps.model.JpsElement)2 JpsPackagingElement (org.jetbrains.jps.model.artifact.elements.JpsPackagingElement)2 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)2 BuildFileProperty (com.intellij.lang.ant.config.impl.BuildFileProperty)1 SmartList (com.intellij.util.SmartList)1 HashMap (com.intellij.util.containers.HashMap)1 HashSet (com.intellij.util.containers.HashSet)1 MultiMap (com.intellij.util.containers.MultiMap)1 TIntObjectHashMap (gnu.trove.TIntObjectHashMap)1