mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
correctly put web and ejb artifacts in ear artifact && unused classes removed
This commit is contained in:
-72
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.packaging.impl.elements;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.elements.ComplexPackagingElementType;
|
||||
import com.intellij.packaging.elements.CompositePackagingElement;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModuleWithDependenciesElementType extends ComplexPackagingElementType<ModuleWithDependenciesPackagingElement> {
|
||||
public static final ModuleWithDependenciesElementType MODULE_WITH_DEPENDENCIES_TYPE = new ModuleWithDependenciesElementType();
|
||||
|
||||
public ModuleWithDependenciesElementType() {
|
||||
super("module-with-dependencies", "Module With Dependencies");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShowContentActionText() {
|
||||
return "Module with dependencies";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getCreateElementIcon() {
|
||||
return IconLoader.getIcon("/nodes/ModuleOpen.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact) {
|
||||
return context.getModulesProvider().getModules().length > 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<? extends ModuleWithDependenciesPackagingElement> chooseAndCreate(@NotNull ArtifactEditorContext context,
|
||||
@NotNull Artifact artifact,
|
||||
@NotNull CompositePackagingElement<?> parent) {
|
||||
final List<Module> modules = ModuleOutputElementType.chooseModules(context);
|
||||
final List<ModuleWithDependenciesPackagingElement> elements = new ArrayList<ModuleWithDependenciesPackagingElement>();
|
||||
for (Module module : modules) {
|
||||
elements.add(new ModuleWithDependenciesPackagingElement(module.getName()));
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ModuleWithDependenciesPackagingElement createEmpty(@NotNull Project project) {
|
||||
return new ModuleWithDependenciesPackagingElement();
|
||||
}
|
||||
}
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.packaging.impl.elements;
|
||||
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.packaging.elements.ComplexPackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementFactory;
|
||||
import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import com.intellij.packaging.impl.ui.DelegatedPackagingElementPresentation;
|
||||
import com.intellij.packaging.impl.ui.ModuleElementPresentation;
|
||||
import com.intellij.packaging.ui.PackagingElementPresentation;
|
||||
import com.intellij.packaging.ui.PackagingElementWeights;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModuleWithDependenciesPackagingElement extends ComplexPackagingElement<ModuleWithDependenciesPackagingElement> {
|
||||
private String myModuleName;
|
||||
|
||||
public ModuleWithDependenciesPackagingElement() {
|
||||
super(ModuleWithDependenciesElementType.MODULE_WITH_DEPENDENCIES_TYPE);
|
||||
}
|
||||
|
||||
public ModuleWithDependenciesPackagingElement(String moduleName) {
|
||||
super(ModuleWithDependenciesElementType.MODULE_WITH_DEPENDENCIES_TYPE);
|
||||
myModuleName = moduleName;
|
||||
}
|
||||
|
||||
public List<? extends PackagingElement<?>> getSubstitution(@NotNull PackagingElementResolvingContext context, @NotNull ArtifactType artifactType) {
|
||||
final Module module = findModule(context);
|
||||
|
||||
List<PackagingElement<?>> elements = new ArrayList<PackagingElement<?>>();
|
||||
final PackagingElementFactory factory = PackagingElementFactory.getInstance();
|
||||
if (module != null) {
|
||||
final ModuleRootModel rootModel = context.getModulesProvider().getRootModel(module);
|
||||
for (OrderEntry entry : rootModel.getOrderEntries()) {
|
||||
if (entry instanceof ModuleSourceOrderEntry) {
|
||||
elements.add(factory.createModuleOutput(myModuleName, context.getProject()));
|
||||
}
|
||||
else if (entry instanceof LibraryOrderEntry) {
|
||||
final Library library = ((LibraryOrderEntry)entry).getLibrary();
|
||||
if (library != null) {
|
||||
elements.addAll(factory.createLibraryElements(library));
|
||||
}
|
||||
}
|
||||
else if (entry instanceof ModuleOrderEntry) {
|
||||
elements.add(new ModuleWithDependenciesPackagingElement(((ModuleOrderEntry)entry).getModuleName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<PackagingElement<?>> substitution = new ArrayList<PackagingElement<?>>();
|
||||
for (PackagingElement<?> element : elements) {
|
||||
final String path = artifactType.getDefaultPathFor(element, context);
|
||||
if (path != null) {
|
||||
substitution.add(factory.createParentDirectories(path, element));
|
||||
}
|
||||
}
|
||||
return substitution;
|
||||
}
|
||||
|
||||
public PackagingElementPresentation createPresentation(@NotNull ArtifactEditorContext context) {
|
||||
return new DelegatedPackagingElementPresentation(new ModuleElementPresentation(myModuleName, findModule(context), context) {
|
||||
@Override
|
||||
protected String getNodeText() {
|
||||
return CompilerBundle.message("node.text.0.with.dependencies", getPresentableName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeight() {
|
||||
return PackagingElementWeights.ARTIFACT - 10;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isEqualTo(@NotNull PackagingElement<?> element) {
|
||||
return element instanceof ModuleWithDependenciesPackagingElement && myModuleName != null
|
||||
&& myModuleName.equals(((ModuleWithDependenciesPackagingElement)element).getModuleName());
|
||||
}
|
||||
|
||||
public ModuleWithDependenciesPackagingElement getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void loadState(ModuleWithDependenciesPackagingElement state) {
|
||||
myModuleName = state.getModuleName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Module findModule(PackagingElementResolvingContext context) {
|
||||
return context.getModulesProvider().getModule(myModuleName);
|
||||
}
|
||||
|
||||
@Attribute("module-name")
|
||||
public String getModuleName() {
|
||||
return myModuleName;
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
myModuleName = moduleName;
|
||||
}
|
||||
}
|
||||
-1
@@ -64,7 +64,6 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
private static final PackagingElementType[] STANDARD_TYPES = {
|
||||
DIRECTORY_ELEMENT_TYPE, ARCHIVE_ELEMENT_TYPE,
|
||||
LibraryElementType.LIBRARY_ELEMENT_TYPE, ModuleOutputElementType.MODULE_OUTPUT_ELEMENT_TYPE,
|
||||
//ModuleWithDependenciesElementType.MODULE_WITH_DEPENDENCIES_TYPE,
|
||||
ArtifactElementType.ARTIFACT_ELEMENT_TYPE, FILE_COPY_ELEMENT_TYPE, DIRECTORY_COPY_ELEMENT_TYPE
|
||||
};
|
||||
|
||||
|
||||
@@ -60,11 +60,6 @@ public abstract class ArtifactType {
|
||||
return getDefaultPathFor(sourceItem.getKindOfProducedElements());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDefaultPathFor(@NotNull PackagingElement<?> element, @NotNull PackagingElementResolvingContext context) {
|
||||
return getDefaultPathFor(element.getFilesKind(context));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract String getDefaultPathFor(@NotNull PackagingElementOutputKind kind);
|
||||
|
||||
|
||||
+4
@@ -64,6 +64,10 @@ public class ArtifactSourceItem extends PackagingSourceItem {
|
||||
return myArtifact.getArtifactType() instanceof JarArtifactType ? PackagingElementOutputKind.JAR_FILES : PackagingElementOutputKind.OTHER;
|
||||
}
|
||||
|
||||
public Artifact getArtifact() {
|
||||
return myArtifact;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myArtifact.hashCode();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user