Search in sources :

Example 1 with JpsPackagingElement

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

the class JpsLibraryFilesPackagingElementImpl method getSubstitution.

@Override
public List<JpsPackagingElement> getSubstitution() {
    JpsLibrary library = getLibraryReference().resolve();
    if (library == null)
        return Collections.emptyList();
    List<JpsPackagingElement> result = new ArrayList<>();
    for (File file : library.getFiles(JpsOrderRootType.COMPILED)) {
        String path = FileUtil.toSystemIndependentName(file.getAbsolutePath());
        if (file.isDirectory()) {
            result.add(JpsPackagingElementFactory.getInstance().createDirectoryCopy(path));
        } else {
            result.add(JpsPackagingElementFactory.getInstance().createFileCopy(path, null));
        }
    }
    return result;
}
Also used : JpsPackagingElement(org.jetbrains.jps.model.artifact.elements.JpsPackagingElement) ArrayList(java.util.ArrayList) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) File(java.io.File)

Example 2 with JpsPackagingElement

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

the class RebuildArtifactOnConfigurationChangeTest method testAddRootChangingRootIndices.

public void testAddRootChangingRootIndices() {
    String file1 = createFile("d1/a/b/1.txt");
    String file2 = createFile("d2/x/y/2.txt");
    JpsArtifact a = addArtifact(root().fileCopy(file1).fileCopy(file2));
    buildAll();
    assertOutput(a, fs().file("1.txt").file("2.txt"));
    JpsCompositePackagingElement root = a.getRootElement();
    assertEquals(2, root.getChildren().size());
    JpsPackagingElement last = root.getChildren().get(1);
    root.removeChild(last);
    String file3 = createFile("d3/1/2/3.txt");
    root.addChild(JpsPackagingElementFactory.getInstance().createFileCopy(file3, null));
    root.addChild(last);
    buildAll();
    assertOutput(a, fs().file("1.txt").file("2.txt").file("3.txt"));
}
Also used : JpsPackagingElement(org.jetbrains.jps.model.artifact.elements.JpsPackagingElement) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) JpsCompositePackagingElement(org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement)

Example 3 with JpsPackagingElement

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

the class JpsArtifactOutputPackagingElementImpl method getSubstitution.

@Override
public List<JpsPackagingElement> getSubstitution() {
    JpsArtifact artifact = getArtifactReference().resolve();
    if (artifact == null)
        return Collections.emptyList();
    JpsCompositePackagingElement rootElement = artifact.getRootElement();
    if (rootElement instanceof JpsArtifactRootElement) {
        return new ArrayList<>(rootElement.getChildren());
    } else {
        return Collections.<JpsPackagingElement>singletonList(rootElement);
    }
}
Also used : JpsPackagingElement(org.jetbrains.jps.model.artifact.elements.JpsPackagingElement) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) ArrayList(java.util.ArrayList) JpsArtifactRootElement(org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement) JpsCompositePackagingElement(org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement)

Aggregations

JpsPackagingElement (org.jetbrains.jps.model.artifact.elements.JpsPackagingElement)3 ArrayList (java.util.ArrayList)2 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)2 JpsCompositePackagingElement (org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement)2 File (java.io.File)1 JpsArtifactRootElement (org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement)1 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)1