use of com.intellij.packaging.elements.PackagingElementResolvingContext 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.elements.PackagingElementResolvingContext in project intellij-community by JetBrains.
the class AppEngineUploader method createUploader.
@Nullable
public static AppEngineUploader createUploader(@NotNull Project project, @NotNull Artifact artifact, @NotNull AppEngineServerConfiguration configuration, @NotNull ServerRuntimeInstance.DeploymentOperationCallback callback, @NotNull LoggingHandler loggingHandler) {
final String explodedPath = artifact.getOutputPath();
if (explodedPath == null) {
callback.errorOccurred("Output path isn't specified for '" + artifact.getName() + "' artifact");
return null;
}
final AppEngineFacet appEngineFacet = AppEngineUtil.findAppEngineFacet(project, artifact);
if (appEngineFacet == null) {
callback.errorOccurred("App Engine facet not found in '" + artifact.getName() + "' artifact");
return null;
}
final AppEngineSdk sdk = appEngineFacet.getSdk();
if (!sdk.getAppCfgFile().exists()) {
callback.errorOccurred("Path to App Engine SDK isn't specified correctly in App Engine Facet settings");
return null;
}
PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
VirtualFile descriptorFile = ArtifactUtil.findSourceFileByOutputPath(artifact, "WEB-INF/appengine-web.xml", context);
final AppEngineWebApp root = AppEngineFacet.getDescriptorRoot(descriptorFile, appEngineFacet.getModule().getProject());
if (root != null) {
final GenericDomValue<String> application = root.getApplication();
if (StringUtil.isEmptyOrSpaces(application.getValue())) {
final String name = Messages.showInputDialog(project, "<html>Application name is not specified in appengine-web.xml.<br>" + "Enter application name (see your <a href=\"http://appengine.google.com\">AppEngine account</a>):</html>", CommonBundle.getErrorTitle(), null, "", null);
if (name == null)
return null;
final PsiFile file = application.getXmlTag().getContainingFile();
new WriteCommandAction(project, file) {
protected void run(@NotNull final Result result) {
application.setStringValue(name);
}
}.execute();
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
if (document != null) {
FileDocumentManager.getInstance().saveDocument(document);
}
}
}
AppEngineAuthData authData = AppEngineAccountDialog.createAuthData(project, configuration);
if (authData == null)
return null;
return new AppEngineUploader(project, artifact, appEngineFacet, sdk, authData, callback, loggingHandler);
}
use of com.intellij.packaging.elements.PackagingElementResolvingContext in project android by JetBrains.
the class AndroidArtifactUtil method getPackagedFacet.
@Nullable
public static AndroidFacet getPackagedFacet(Project project, Artifact artifact) {
final Ref<AndroidFinalPackageElement> elementRef = Ref.create(null);
final PackagingElementResolvingContext resolvingContext = ArtifactManager.getInstance(project).getResolvingContext();
ArtifactUtil.processPackagingElements(artifact, AndroidFinalPackageElementType.getInstance(), new Processor<AndroidFinalPackageElement>() {
@Override
public boolean process(AndroidFinalPackageElement e) {
elementRef.set(e);
return false;
}
}, resolvingContext, true);
final AndroidFinalPackageElement element = elementRef.get();
return element != null ? element.getFacet() : null;
}
use of com.intellij.packaging.elements.PackagingElementResolvingContext 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