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;
}
Aggregations