Search in sources :

Example 1 with JpsArtifactOutputPackagingElement

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

the class ArtifactBuildTarget method computeDependencies.

@Override
public Collection<BuildTarget<?>> computeDependencies(BuildTargetRegistry targetRegistry, final TargetOutputIndex outputIndex) {
    final LinkedHashSet<BuildTarget<?>> dependencies = new LinkedHashSet<>();
    final JpsArtifact artifact = getArtifact();
    JpsArtifactUtil.processPackagingElements(artifact.getRootElement(), element -> {
        if (element instanceof JpsArtifactOutputPackagingElement) {
            JpsArtifact included = ((JpsArtifactOutputPackagingElement) element).getArtifactReference().resolve();
            if (included != null && !included.equals(artifact)) {
                if (!StringUtil.isEmpty(included.getOutputPath())) {
                    dependencies.add(new ArtifactBuildTarget(included));
                    return false;
                }
            }
        }
        dependencies.addAll(LayoutElementBuildersRegistry.getInstance().getDependencies(element, outputIndex));
        return true;
    });
    if (!dependencies.isEmpty()) {
        final List<BuildTarget<?>> additional = new SmartList<>();
        for (BuildTarget<?> dependency : dependencies) {
            if (dependency instanceof ModuleBasedTarget<?>) {
                final ModuleBasedTarget target = (ModuleBasedTarget) dependency;
                additional.addAll(targetRegistry.getModuleBasedTargets(target.getModule(), target.isTests() ? BuildTargetRegistry.ModuleTargetSelector.TEST : BuildTargetRegistry.ModuleTargetSelector.PRODUCTION));
            }
        }
        dependencies.addAll(additional);
    }
    return dependencies;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) SmartList(com.intellij.util.SmartList) JpsArtifactOutputPackagingElement(org.jetbrains.jps.model.artifact.elements.JpsArtifactOutputPackagingElement)

Aggregations

SmartList (com.intellij.util.SmartList)1 LinkedHashSet (java.util.LinkedHashSet)1 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)1 JpsArtifactOutputPackagingElement (org.jetbrains.jps.model.artifact.elements.JpsArtifactOutputPackagingElement)1