use of com.intellij.packaging.artifacts.ArtifactManager 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.artifacts.ArtifactManager in project intellij-community by JetBrains.
the class ArtifactsTestUtil method findArtifact.
public static Artifact findArtifact(Project project, String artifactName) {
final ArtifactManager manager = ArtifactManager.getInstance(project);
final Artifact artifact = manager.findArtifact(artifactName);
assertNotNull("'" + artifactName + "' artifact not found", artifact);
return artifact;
}
use of com.intellij.packaging.artifacts.ArtifactManager in project intellij-community by JetBrains.
the class AppEngineSupportProvider method findOrCreateWebArtifact.
@NotNull
private static Artifact findOrCreateWebArtifact(AppEngineFacet appEngineFacet) {
Module module = appEngineFacet.getModule();
ArtifactType webArtifactType = AppEngineWebIntegration.getInstance().getAppEngineWebArtifactType();
final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
for (Artifact artifact : artifacts) {
if (webArtifactType.equals(artifact.getArtifactType())) {
return artifact;
}
}
ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
return artifactManager.addArtifact(module.getName(), webArtifactType, root);
}
use of com.intellij.packaging.artifacts.ArtifactManager in project android by JetBrains.
the class NonGradleApkProviderTest method testGetApksWithArtifactName.
public void testGetApksWithArtifactName() throws Exception {
IDevice device = Mockito.mock(IDevice.class);
ArtifactManager artifactManager = ArtifactManager.getInstance(myFacet.getModule().getProject());
CompositePackagingElement<?> archive = PackagingElementFactory.getInstance().createArchive("right.apk");
archive.addFirstChild(new AndroidFinalPackageElement(myFacet.getModule().getProject(), myFacet));
artifactManager.addArtifact("customApk", AndroidApplicationArtifactType.getInstance(), archive);
myFacet.getProperties().APK_PATH = "wrong.apk";
NonGradleApkProvider provider = new NonGradleApkProvider(myFacet, new NonGradleApplicationIdProvider(myFacet), "customApk");
Collection<ApkInfo> apks = provider.getApks(device);
assertNotNull(apks);
assertEquals(1, apks.size());
ApkInfo apk = apks.iterator().next();
assertEquals("p1.p2", apk.getApplicationId());
assertTrue(apk.getFile().getPath().endsWith("right.apk"));
}
use of com.intellij.packaging.artifacts.ArtifactManager 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;
}
Aggregations