[271802] Need a hook for adoptors to disable classpath attribute org.eclipse.jst.component.dependency
diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentLoadStrategyImpl.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentLoadStrategyImpl.java index 1dbc63d..f24bfd0 100644 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentLoadStrategyImpl.java +++ b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/ComponentLoadStrategyImpl.java
@@ -44,6 +44,7 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; import org.eclipse.jem.util.logger.proxy.Logger; +import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; import org.eclipse.jst.j2ee.commonarchivecore.internal.File; import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ResourceLoadException; @@ -208,7 +209,7 @@ filesHolder = new FilesHolder(); exception = new Exception(); this.includeClasspathComponents = includeClasspathComponents; - if (includeClasspathComponents) { + if (includeClasspathComponents && ClasspathDependencyUtil.isAllowClasspathComponentDependency()) { this.manifestFile = vComponent.getRootFolder().getFile(new Path(J2EEConstants.MANIFEST_URI)); saveJavaClasspathReferences(); }
diff --git a/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/classpathdep/ClasspathDependencyUtil.java b/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/classpathdep/ClasspathDependencyUtil.java index 8f93f64..d58e53a 100644 --- a/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/classpathdep/ClasspathDependencyUtil.java +++ b/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/classpathdep/ClasspathDependencyUtil.java
@@ -54,6 +54,21 @@ public class ClasspathDependencyUtil implements IClasspathDependencyConstants { /** + * This flag is used to control the enablement of the Classpath Dependency + * functionality. The default value is true which enables this functionality. + * Setting this value to false will disable the functionality. + */ + private static boolean allowClasspathComponentDependnecy = true; + + public static void setAllowClasspathComponentDependency(boolean allow){ + allowClasspathComponentDependnecy = allow; + } + + public static boolean isAllowClasspathComponentDependency(){ + return allowClasspathComponentDependnecy; + } + + /** * This is equivalent to calling getRawComponentClasspathDependencies(javaProject, DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY); * * @deprecated use {@link #getRawComponentClasspathDependencies(IJavaProject, org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants.DependencyAttributeType)} @@ -77,7 +92,7 @@ * @throws CoreException Thrown if an error is encountered accessing the unresolved classpath. */ public static Map getRawComponentClasspathDependencies(final IJavaProject javaProject, DependencyAttributeType attributeType) throws CoreException { - if (javaProject == null) { + if (javaProject == null || !isAllowClasspathComponentDependency()) { return Collections.EMPTY_MAP; } final Map referencedRawEntries = new HashMap(); @@ -105,7 +120,7 @@ public static List getPotentialComponentClasspathDependencies(final IJavaProject javaProject) throws CoreException { final List potentialRawEntries = new ArrayList(); - if (javaProject == null || !javaProject.getProject().isAccessible()) { + if (javaProject == null || !javaProject.getProject().isAccessible() || !isAllowClasspathComponentDependency()) { return Collections.EMPTY_LIST; } final IProject project = javaProject.getProject(); @@ -258,7 +273,10 @@ * @throws CoreException Thrown if an error is encountered accessing the unresolved classpath. */ public static Map getComponentClasspathDependencies(final IJavaProject javaProject, final boolean isWebApp, final boolean onlyValid) throws CoreException { - + if(!isAllowClasspathComponentDependency()){ + return Collections.EMPTY_MAP; + } + final ClasspathDependencyValidatorData data = new ClasspathDependencyValidatorData(javaProject.getProject()); // get the raw entries @@ -565,7 +583,7 @@ * @return The IClasspathAttribute that holds the special WTP attribute or null if one was not found. */ public static IClasspathAttribute checkForComponentDependencyAttribute(final IClasspathEntry entry, final DependencyAttributeType attributeType) { - if (entry == null) { + if (entry == null || !isAllowClasspathComponentDependency()) { return null; } final IClasspathAttribute[] attributes = entry.getExtraAttributes();
diff --git a/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/internal/classpathdep/ClasspathDependencyValidator.java b/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/internal/classpathdep/ClasspathDependencyValidator.java index c8909fc..ea910c8 100644 --- a/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/internal/classpathdep/ClasspathDependencyValidator.java +++ b/plugins/org.eclipse.jst.j2ee/classpathdep/org/eclipse/jst/j2ee/internal/classpathdep/ClasspathDependencyValidator.java
@@ -72,6 +72,9 @@ public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws ValidationException { + if(!ClasspathDependencyUtil.isAllowClasspathComponentDependency()){ + return OK_STATUS; + } _reporter = reporter; //Remove all markers related to this validator _reporter.removeAllMessages(this);
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java index d1c9d3e..25a372a 100644 --- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java +++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/ClasspathModel.java
@@ -645,12 +645,13 @@ classPathWLPSelection.addClasspathElement(element, unresolvedURI); } } - - // Add elements for raw classpath entries (either already tagged or potentially taggable) - try { - classPathWLPSelection.createClasspathEntryElements(component, WEBLIB, WEBINF_CLASSES); - } catch (CoreException ce) { - Logger.getLogger(J2EEPlugin.PLUGIN_ID).logError(ce); + if(ClasspathDependencyUtil.isAllowClasspathComponentDependency()){ + // Add elements for raw classpath entries (either already tagged or potentially taggable) + try { + classPathWLPSelection.createClasspathEntryElements(component, WEBLIB, WEBINF_CLASSES); + } catch (CoreException ce) { + Logger.getLogger(J2EEPlugin.PLUGIN_ID).logError(ce); + } } }
diff --git a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java index 031fa87..5ce9220 100644 --- a/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java +++ b/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/ClassPathSelection.java
@@ -660,10 +660,12 @@ //createClasspathComponentDependencyElements(comp); // Add elements for raw classpath entries (either already tagged or potentially taggable) - try { - createClasspathEntryElements(component, IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH, IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_COMPONENT_PATH); - } catch (CoreException ce) { - Logger.getLogger(J2EEPlugin.PLUGIN_ID).logError(ce); + if(ClasspathDependencyUtil.isAllowClasspathComponentDependency()){ + try { + createClasspathEntryElements(component, IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH, IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_COMPONENT_PATH); + } catch (CoreException ce) { + Logger.getLogger(J2EEPlugin.PLUGIN_ID).logError(ce); + } } if (earComponent != null) {
diff --git a/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java b/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java index 948d65e..5077f69 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java +++ b/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java
@@ -177,6 +177,9 @@ } private IVirtualReference[] getJavaClasspathReferences(IVirtualReference[] hardReferences) { + if(!ClasspathDependencyUtil.isAllowClasspathComponentDependency()){ + return new IVirtualReference[0]; + } final IProject project = getProject(); final List cpRefs = new ArrayList(); final boolean isWebApp = J2EEProjectUtilities.isDynamicWebComponent(this);