Search in sources :

Example 16 with JpsArtifact

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

the class ArtifactBuilderTest method testManifestFileIsFirstEntry.

//IDEA-73893
public void testManifestFileIsFirstEntry() throws IOException {
    final String firstFile = createFile("src/A.txt");
    final String manifestFile = createFile("src/MANIFEST.MF");
    final String lastFile = createFile("src/Z.txt");
    final JpsArtifact a = addArtifact(archive("a.jar").dir("META-INF").fileCopy(firstFile).fileCopy(manifestFile).fileCopy(lastFile));
    buildArtifacts(a);
    final String jarPath = a.getOutputPath() + "/a.jar";
    JarFile jarFile = new JarFile(new File(jarPath));
    try {
        final Enumeration<JarEntry> entries = jarFile.entries();
        assertTrue(entries.hasMoreElements());
        final JarEntry firstEntry = entries.nextElement();
        assertEquals(JarFile.MANIFEST_NAME, firstEntry.getName());
    } finally {
        jarFile.close();
    }
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry) JarFile(java.util.jar.JarFile) File(java.io.File) ZipFile(java.util.zip.ZipFile)

Example 17 with JpsArtifact

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

the class CleanArtifactOutputOnRebuildTest method testDoNotCleanIfContainsSourceFolder.

public void testDoNotCleanIfContainsSourceFolder() {
    JpsArtifact a = addArtifact(root().fileCopy(createFile("a.txt")));
    addModule("m", a.getOutputPath() + "/src");
    buildArtifacts(a);
    createFileInArtifactOutput(a, "b.txt");
    rebuildAllModulesAndArtifacts();
    assertOutput(a, fs().file("a.txt").file("b.txt"));
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 18 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact 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 19 with JpsArtifact

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

the class ArtifactBuilderTest method testDeleteOnlyOutputFileOnRebuildForArchiveArtifact.

public void testDeleteOnlyOutputFileOnRebuildForArchiveArtifact() throws IOException {
    String file = createFile("a.txt");
    JpsArtifact a = addArtifact(archive("a.jar").fileCopy(file));
    buildAll();
    createFileInArtifactOutput(a, "b.txt");
    buildAllAndAssertUpToDate();
    assertOutput(a, fs().archive("a.jar").file("a.txt").end().file("b.txt"));
    rebuildAllModulesAndArtifacts();
    assertOutput(a, fs().archive("a.jar").file("a.txt").end().file("b.txt"));
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 20 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact 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)

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