Search in sources :

Example 46 with JpsArtifact

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

the class ArtifactBuilderTest method testCopyExcludedFile.

public void testCopyExcludedFile() {
    //excluded files under non-excluded directory should not be copied
    final String file = createFile("xxx/excluded/a.txt");
    createFile("xxx/b.txt");
    createFile("xxx/CVS");
    final String dir = PathUtil.getParentPath(PathUtil.getParentPath(file));
    JpsModule module = addModule("myModule");
    module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(dir));
    module.getExcludeRootsList().addUrl(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)));
    final JpsArtifact a = addArtifact(root().dirCopy(dir));
    buildAll();
    assertOutput(a, fs().file("b.txt"));
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 47 with JpsArtifact

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

the class ArtifactBuilderTest method testModuleOutput.

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

Example 48 with JpsArtifact

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

the class ArtifactBuilderTest method testPreserveCompressionMethodForEntryExtractedFromOneArchiveAndPackedIntoAnother.

public void testPreserveCompressionMethodForEntryExtractedFromOneArchiveAndPackedIntoAnother() throws IOException {
    String path = createFile("data/a.jar");
    ZipOutputStream output = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(new File(path))));
    try {
        ZipEntry entry = new ZipEntry("a.txt");
        byte[] text = "text".getBytes();
        entry.setMethod(ZipEntry.STORED);
        entry.setSize(text.length);
        CRC32 crc32 = new CRC32();
        crc32.update(text);
        entry.setCrc(crc32.getValue());
        output.putNextEntry(entry);
        output.write(text);
        output.closeEntry();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        output.close();
    }
    JpsArtifact a = addArtifact(archive("b.jar").extractedDir(path, ""));
    buildAll();
    assertOutput(a, fs().archive("b.jar").file("a.txt", "text"));
    final String jarPath = a.getOutputPath() + "/b.jar";
    ZipFile zipFile = new ZipFile(new File(jarPath));
    try {
        ZipEntry entry = zipFile.getEntry("a.txt");
        assertNotNull(entry);
        assertEquals(ZipEntry.STORED, entry.getMethod());
    } finally {
        zipFile.close();
    }
}
Also used : ZipFile(java.util.zip.ZipFile) CRC32(java.util.zip.CRC32) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) ZipEntry(java.util.zip.ZipEntry) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) BufferedOutputStream(java.io.BufferedOutputStream) JarFile(java.util.jar.JarFile) File(java.io.File) ZipFile(java.util.zip.ZipFile) IOException(java.io.IOException)

Example 49 with JpsArtifact

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

the class ArtifactBuilderTest method testIgnoredFileInArchive.

public void testIgnoredFileInArchive() {
    final String file = createFile("a/.svn/a.txt");
    createFile("a/svn/b.txt");
    final JpsArtifact a = addArtifact(archive("a.jar").parentDirCopy(PathUtil.getParentPath(file)));
    buildAll();
    assertOutput(a, fs().archive("a.jar").dir("svn").file("b.txt"));
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 50 with JpsArtifact

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

the class ArtifactBuilderTestCase method addArtifact.

protected JpsArtifact addArtifact(String name, LayoutElementTestUtil.LayoutElementCreator root) {
    assertFalse("JpsArtifact " + name + " already exists", getArtifactNames().contains(name));
    JpsArtifact artifact = JpsArtifactService.getInstance().addArtifact(myProject, name, root.buildElement(), DirectoryArtifactType.INSTANCE, JpsElementFactory.getInstance().createDummyElement());
    artifact.setOutputPath(getAbsolutePath("out/artifacts/" + name));
    return artifact;
}
Also used : 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