本文整理汇总了Java中com.intellij.packaging.impl.artifacts.ArtifactUtil类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactUtil类的具体用法?Java ArtifactUtil怎么用?Java ArtifactUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactUtil类属于com.intellij.packaging.impl.artifacts包,在下文中一共展示了ArtifactUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUsagesInElement
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
final Artifact artifact = myArtifactsStructureContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
final List<ProjectStructureElementUsage> usages = new ArrayList<ProjectStructureElementUsage>();
final CompositePackagingElement<?> rootElement = myArtifactsStructureContext.getRootElement(artifact);
ArtifactUtil.processPackagingElements(rootElement, null, new PackagingElementProcessor<PackagingElement<?>>() {
@Override
public boolean process(@NotNull PackagingElement<?> packagingElement, @NotNull PackagingElementPath path) {
ProjectStructureElement element = getProjectStructureElementFor(packagingElement, ArtifactProjectStructureElement.this.myContext,
ArtifactProjectStructureElement.this.myArtifactsStructureContext);
if (element != null) {
usages.add(createUsage(packagingElement, element, path.getPathStringFrom("/", rootElement)));
}
return true;
}
}, myArtifactsStructureContext, false, artifact.getArtifactType());
return usages;
}
示例2: getNotAddedLibraries
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static List<? extends Library> getNotAddedLibraries(@NotNull final ArtifactEditorContext context, @NotNull Artifact artifact,
List<Library> librariesList) {
final Set<VirtualFile> roots = new HashSet<VirtualFile>();
ArtifactUtil.processPackagingElements(artifact, PackagingElementFactoryImpl.FILE_COPY_ELEMENT_TYPE, new Processor<FileCopyPackagingElement>() {
@Override
public boolean process(FileCopyPackagingElement fileCopyPackagingElement) {
final VirtualFile root = fileCopyPackagingElement.getLibraryRoot();
if (root != null) {
roots.add(root);
}
return true;
}
}, context, true);
final List<Library> result = new ArrayList<Library>();
for (Library library : librariesList) {
if (!roots.containsAll(Arrays.asList(library.getFiles(OrderRootType.CLASSES)))) {
result.add(library);
}
}
return result;
}
示例3: getSourceItems
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@NotNull
@Override
public Collection<? extends PackagingSourceItem> getSourceItems(@NotNull ArtifactEditorContext editorContext, @NotNull Artifact artifact,
@Nullable PackagingSourceItem parent) {
if (parent instanceof ModuleSourceItemGroup) {
final Module module = ((ModuleSourceItemGroup)parent).getModule();
final Set<F> facets = new HashSet<F>(editorContext.getFacetsProvider().getFacetsByType(module, myFacetTypeId));
ArtifactUtil.processPackagingElements(artifact, myElementType, new Processor<E>() {
@Override
public boolean process(E e) {
F facet = getFacet(e);
if (facet != null) {
facets.remove(facet);
}
return true;
}
}, editorContext, true);
if (!facets.isEmpty()) {
return Collections.singletonList(new FacetBasedSourceItem<F>(this, facets.iterator().next()));
}
}
return Collections.emptyList();
}
示例4: updateOutputPath
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
public void updateOutputPath(@NotNull String oldArtifactName, @NotNull final String newArtifactName) {
final String oldDefaultPath = ArtifactUtil.getDefaultArtifactOutputPath(oldArtifactName, myProject);
if (Comparing.equal(oldDefaultPath, getConfiguredOutputPath())) {
setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject));
}
final CompositePackagingElement<?> root = getRootElement();
if (root instanceof ArchivePackagingElement) {
String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
final String name = ((ArchivePackagingElement)root).getArchiveFileName();
final String fileName = FileUtil.getNameWithoutExtension(name);
final String extension = FileUtilRt.getExtension(name);
if (fileName.equals(oldFileName) && extension.length() > 0) {
myLayoutTreeComponent.editLayout(new Runnable() {
@Override
public void run() {
((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension);
}
});
myLayoutTreeComponent.updateRootNode();
}
}
}
示例5: collectIncludedArtifacts
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static void collectIncludedArtifacts(Artifact artifact, final PackagingElementResolvingContext context,
final Set<Artifact> processed, final Set<Artifact> result, final boolean withOutputPathOnly) {
if (!processed.add(artifact)) {
return;
}
if (!withOutputPathOnly || !StringUtil.isEmpty(artifact.getOutputPath())) {
result.add(artifact);
}
ArtifactUtil.processPackagingElements(artifact, ArtifactElementType.ARTIFACT_ELEMENT_TYPE, new Processor<ArtifactPackagingElement>() {
@Override
public boolean process(ArtifactPackagingElement element) {
Artifact included = element.findArtifact(context);
if (included != null) {
collectIncludedArtifacts(included, context, processed, result, withOutputPathOnly);
}
return true;
}
}, context, false);
}
示例6: findOrCreateWebArtifact
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@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);
}
示例7: findClass
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@Override
protected PsiClass findClass(String className) {
final Set<Module> modules = ApplicationManager.getApplication().runReadAction(new Computable<Set<Module>>() {
@Override
public Set<Module> compute() {
return ArtifactUtil.getModulesIncludedInArtifacts(Collections.singletonList(myArtifact), getProject());
}
});
for (Module module : modules) {
final PsiClass aClass = JavaExecutionUtil.findMainClass(getProject(), className, GlobalSearchScope.moduleScope(module));
if (aClass != null) {
return aClass;
}
}
return null;
}
示例8: findOrCreateWebArtifact
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@NotNull
static Artifact findOrCreateWebArtifact(AppEngineStandardFacet appEngineStandardFacet) {
Module module = appEngineStandardFacet.getModule();
ArtifactType webArtifactType =
AppEngineStandardWebIntegration.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);
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:20,代码来源:AppEngineStandardSupportProvider.java
示例9: findOneAppEngineStandardArtifact
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
/**
* Returns the only app engine standard artifact found for the given module or null if there
* aren't any or more than one.
*/
@Nullable
public static Artifact findOneAppEngineStandardArtifact(@NotNull Module module) {
Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
Collection<Artifact> appEngineStandardArtifacts = Lists.newArrayList();
appEngineStandardArtifacts.addAll(
artifacts
.stream()
.filter(
artifact ->
AppEngineProjectService.getInstance().isAppEngineStandardArtifactType(artifact))
.collect(toList()));
return appEngineStandardArtifacts.size() == 1
? appEngineStandardArtifacts.iterator().next()
: null;
}
示例10: updateOutputPath
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
public void updateOutputPath(@NotNull String oldArtifactName, @NotNull final String newArtifactName) {
final String oldDefaultPath = ArtifactUtil.getDefaultArtifactOutputPath(oldArtifactName, myProject);
if (Comparing.equal(oldDefaultPath, getConfiguredOutputPath())) {
setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject));
final CompositePackagingElement<?> root = getRootElement();
if (root instanceof ArchivePackagingElement) {
String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
final String name = ((ArchivePackagingElement)root).getArchiveFileName();
final String fileName = FileUtil.getNameWithoutExtension(name);
final String extension = FileUtilRt.getExtension(name);
if (fileName.equals(oldFileName) && extension.length() > 0) {
myLayoutTreeComponent.editLayout(new Runnable() {
@Override
public void run() {
((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension);
}
});
myLayoutTreeComponent.updateRootNode();
}
}
}
}
示例11: findOrCreateArtifact
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@NotNull
private static Artifact findOrCreateArtifact(AppEngineFacet appEngineFacet) {
Module module = appEngineFacet.getModule();
ArtifactType artifactType = AppEngineWebIntegration.getInstance().getAppEngineTargetArtifactType();
final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
for (Artifact artifact : artifacts) {
if (artifactType.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(), artifactType, root);
}
示例12: collectIncludedArtifacts
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static void collectIncludedArtifacts(Artifact artifact, final PackagingElementResolvingContext context,
final Set<Artifact> processed, final Set<Artifact> result, final boolean withOutputPathOnly) {
if (!processed.add(artifact)) {
return;
}
if (!withOutputPathOnly || !StringUtil.isEmpty(artifact.getOutputPath())) {
result.add(artifact);
}
ArtifactUtil.processPackagingElements(artifact, ArtifactElementType.getInstance(), new Processor<ArtifactPackagingElement>() {
@Override
public boolean process(ArtifactPackagingElement element) {
Artifact included = element.findArtifact(context);
if (included != null) {
collectIncludedArtifacts(included, context, processed, result, withOutputPathOnly);
}
return true;
}
}, context, false);
}
示例13: getUsagesInElement
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
@Override
public List<ProjectStructureElementUsage> getUsagesInElement() {
final Artifact artifact = myArtifactsStructureContext.getArtifactModel().getArtifactByOriginal(myOriginalArtifact);
final List<ProjectStructureElementUsage> usages = new ArrayList<ProjectStructureElementUsage>();
final CompositePackagingElement<?> rootElement = myArtifactsStructureContext.getRootElement(artifact);
ArtifactUtil.processPackagingElements(rootElement, null, new PackagingElementProcessor<PackagingElement<?>>() {
@Override
public boolean process(@Nonnull PackagingElement<?> packagingElement, @Nonnull PackagingElementPath path) {
ProjectStructureElement element = getProjectStructureElementFor(packagingElement, ArtifactProjectStructureElement.this.myContext,
ArtifactProjectStructureElement.this.myArtifactsStructureContext);
if (element != null) {
usages.add(createUsage(packagingElement, element, path.getPathStringFrom("/", rootElement)));
}
return true;
}
}, myArtifactsStructureContext, false, artifact.getArtifactType());
return usages;
}
示例14: getNotAddedLibraries
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
private static List<? extends Library> getNotAddedLibraries(@Nonnull final ArtifactEditorContext context,
@Nonnull Artifact artifact,
List<Library> librariesList) {
final Set<VirtualFile> roots = new HashSet<VirtualFile>();
ArtifactUtil
.processPackagingElements(artifact, FileCopyElementType.getInstance(), new Processor<FileCopyPackagingElement>() {
@Override
public boolean process(FileCopyPackagingElement fileCopyPackagingElement) {
final VirtualFile root = fileCopyPackagingElement.getLibraryRoot();
if (root != null) {
roots.add(root);
}
return true;
}
}, context, true);
final List<Library> result = new ArrayList<Library>();
for (Library library : librariesList) {
if (!roots.containsAll(Arrays.asList(library.getFiles(BinariesOrderRootType.getInstance())))) {
result.add(library);
}
}
return result;
}
示例15: updateOutputPath
import com.intellij.packaging.impl.artifacts.ArtifactUtil; //导入依赖的package包/类
public void updateOutputPath(@Nonnull String oldArtifactName, @Nonnull final String newArtifactName) {
final String oldDefaultPath = ArtifactUtil.getDefaultArtifactOutputPath(oldArtifactName, myProject);
if (Comparing.equal(oldDefaultPath, getConfiguredOutputPath())) {
setOutputPath(ArtifactUtil.getDefaultArtifactOutputPath(newArtifactName, myProject));
final CompositePackagingElement<?> root = getRootElement();
if (root instanceof ArchivePackagingElement) {
String oldFileName = ArtifactUtil.suggestArtifactFileName(oldArtifactName);
final String name = ((ArchivePackagingElement)root).getArchiveFileName();
final String fileName = FileUtil.getNameWithoutExtension(name);
final String extension = FileUtilRt.getExtension(name);
if (fileName.equals(oldFileName) && extension.length() > 0) {
myLayoutTreeComponent.editLayout(new Runnable() {
@Override
public void run() {
((ArchivePackagingElement)getRootElement()).setArchiveFileName(ArtifactUtil.suggestArtifactFileName(newArtifactName) + "." + extension);
}
});
myLayoutTreeComponent.updateRootNode();
}
}
}
}