use of com.intellij.packaging.impl.elements.ModuleOutputPackagingElement in project intellij-community by JetBrains.
the class ArtifactBySourceFileFinderImpl method computeFileToArtifactsMap.
private MultiValuesMap<VirtualFile, Artifact> computeFileToArtifactsMap() {
final MultiValuesMap<VirtualFile, Artifact> result = new MultiValuesMap<>();
final ArtifactManager artifactManager = ArtifactManager.getInstance(myProject);
for (final Artifact artifact : artifactManager.getArtifacts()) {
final PackagingElementResolvingContext context = artifactManager.getResolvingContext();
ArtifactUtil.processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
@Override
public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
if (element instanceof FileOrDirectoryCopyPackagingElement<?>) {
final VirtualFile root = ((FileOrDirectoryCopyPackagingElement) element).findFile();
if (root != null) {
result.put(root, artifact);
}
} else if (element instanceof ModuleOutputPackagingElement) {
for (VirtualFile sourceRoot : ((ModuleOutputPackagingElement) element).getSourceRoots(context)) {
result.put(sourceRoot, artifact);
}
}
return true;
}
}, context, true);
}
return result;
}
use of com.intellij.packaging.impl.elements.ModuleOutputPackagingElement in project intellij-community by JetBrains.
the class ArtifactsGenerator method createArtifactTarget.
private Target createArtifactTarget(Artifact artifact) {
final StringBuilder depends = new StringBuilder(INIT_ARTIFACTS_TARGET);
ArtifactUtil.processRecursivelySkippingIncludedArtifacts(artifact, packagingElement -> {
if (packagingElement instanceof ArtifactPackagingElement) {
final Artifact included = ((ArtifactPackagingElement) packagingElement).findArtifact(myResolvingContext);
if (included != null) {
if (depends.length() > 0)
depends.append(", ");
depends.append(myContext.getTargetName(included));
}
} else if (packagingElement instanceof ModuleOutputPackagingElement) {
final Module module = ((ModuleOutputPackagingElement) packagingElement).findModule(myResolvingContext);
if (module != null) {
if (depends.length() > 0)
depends.append(", ");
depends.append(BuildProperties.getCompileTargetName(module.getName()));
}
}
return true;
}, myResolvingContext);
final Couple<String> xmlNs = getArtifactXmlNs(artifact.getArtifactType());
final Target artifactTarget = new Target(myContext.getTargetName(artifact), depends.toString(), "Build '" + artifact.getName() + "' artifact", null, xmlNs != null ? xmlNs.first : null, xmlNs != null ? xmlNs.second : null);
if (myContext.shouldBuildIntoTempDirectory(artifact)) {
final String outputDirectory = BuildProperties.propertyRelativePath(ArtifactAntGenerationContextImpl.ARTIFACTS_TEMP_DIR_PROPERTY, FileUtil.sanitizeFileName(artifact.getName()));
artifactTarget.add(new Property(myContext.getArtifactOutputProperty(artifact), outputDirectory));
}
final String outputPath = BuildProperties.propertyRef(myContext.getArtifactOutputProperty(artifact));
artifactTarget.add(new Mkdir(outputPath));
generateTasksForArtifacts(artifact, artifactTarget, true);
final DirectoryAntCopyInstructionCreator creator = new DirectoryAntCopyInstructionCreator(outputPath);
List<Generator> copyInstructions = new ArrayList<>();
if (needAntArtifactInstructions(artifact.getArtifactType())) {
copyInstructions.addAll(artifact.getRootElement().computeAntInstructions(myResolvingContext, creator, myContext, artifact.getArtifactType()));
}
for (Generator generator : myContext.getAndClearBeforeCurrentArtifact()) {
artifactTarget.add(generator);
}
for (Generator tag : copyInstructions) {
artifactTarget.add(tag);
}
generateTasksForArtifacts(artifact, artifactTarget, false);
return artifactTarget;
}
Aggregations