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"));
}
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"));
}
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();
}
}
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"));
}
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;
}
Aggregations