use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.
the class ArtifactCompileScope method getArtifactsToBuild.
public static Set<Artifact> getArtifactsToBuild(final Project project, final CompileScope compileScope, final boolean addIncludedArtifactsWithOutputPathsOnly) {
final Artifact[] artifactsFromScope = getArtifacts(compileScope);
final ArtifactManager artifactManager = ArtifactManager.getInstance(project);
PackagingElementResolvingContext context = artifactManager.getResolvingContext();
if (artifactsFromScope != null) {
return addIncludedArtifacts(Arrays.asList(artifactsFromScope), context, addIncludedArtifactsWithOutputPathsOnly);
}
final Set<Artifact> cached = compileScope.getUserData(CACHED_ARTIFACTS_KEY);
if (cached != null) {
return cached;
}
Set<Artifact> artifacts = new HashSet<>();
final Set<Module> modules = new HashSet<>(Arrays.asList(compileScope.getAffectedModules()));
final List<Module> allModules = Arrays.asList(ModuleManager.getInstance(project).getModules());
for (Artifact artifact : artifactManager.getArtifacts()) {
if (artifact.isBuildOnMake()) {
if (modules.containsAll(allModules) || containsModuleOutput(artifact, modules, context)) {
artifacts.add(artifact);
}
}
}
Set<Artifact> result = addIncludedArtifacts(artifacts, context, addIncludedArtifactsWithOutputPathsOnly);
compileScope.putUserData(CACHED_ARTIFACTS_KEY, result);
return result;
}
use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.
the class ArtifactCompilerUtil method createOutputToArtifactMap.
public static MultiMap<String, Artifact> createOutputToArtifactMap(final Project project) {
final MultiMap<String, Artifact> result = MultiMap.create(FileUtil.PATH_HASHING_STRATEGY);
new ReadAction() {
protected void run(@NotNull final Result r) {
for (Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
String outputPath = artifact.getOutputFilePath();
if (!StringUtil.isEmpty(outputPath)) {
result.putValue(outputPath, artifact);
}
}
}
}.execute();
return result;
}
use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.
the class ArtifactsWorkspaceSettings method getArtifactsToBuild.
public List<Artifact> getArtifactsToBuild() {
final List<Artifact> result = new ArrayList<>();
final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
for (String name : myState.myArtifactsToBuild) {
ContainerUtil.addIfNotNull(result, artifactManager.findArtifact(name));
}
return result;
}
use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.
the class ArtifactElementType method chooseAndCreate.
@NotNull
public List<? extends ArtifactPackagingElement> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
final Project project = context.getProject();
List<Artifact> artifacts = context.chooseArtifacts(getAvailableArtifacts(context, artifact, false), CompilerBundle.message("dialog.title.choose.artifacts"));
final List<ArtifactPackagingElement> elements = new ArrayList<>();
for (Artifact selected : artifacts) {
elements.add(new ArtifactPackagingElement(project, ArtifactPointerManager.getInstance(project).createPointer(selected, context.getArtifactModel())));
}
return elements;
}
use of com.intellij.packaging.artifacts.Artifact in project intellij-community by JetBrains.
the class ArtifactPackagingElement method getSubstitution.
public List<? extends PackagingElement<?>> getSubstitution(@NotNull PackagingElementResolvingContext context, @NotNull ArtifactType artifactType) {
final Artifact artifact = findArtifact(context);
if (artifact != null) {
final ArtifactType type = artifact.getArtifactType();
List<? extends PackagingElement<?>> substitution = type.getSubstitution(artifact, context, artifactType);
if (substitution != null) {
return substitution;
}
final List<PackagingElement<?>> elements = new ArrayList<>();
final CompositePackagingElement<?> rootElement = artifact.getRootElement();
if (rootElement instanceof ArtifactRootElement<?>) {
elements.addAll(rootElement.getChildren());
} else {
elements.add(rootElement);
}
return elements;
}
return null;
}
Aggregations