[323744] Classpath dependency enablement should directly control dynamic manifest updating
diff --git a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaEEComponentExportOperation.java b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaEEComponentExportOperation.java index c817d9b..ee8fecd 100644 --- a/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaEEComponentExportOperation.java +++ b/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/operations/JavaEEComponentExportOperation.java
@@ -20,6 +20,7 @@ import org.eclipse.jst.common.internal.modulecore.AddMappedOutputFoldersParticipant; import org.eclipse.jst.common.internal.modulecore.ReplaceManifestExportParticipant; import org.eclipse.jst.j2ee.internal.J2EEConstants; +import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement; import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEEComponentExportCallback; import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant; import org.eclipse.wst.common.componentcore.internal.flat.FilterResourceParticipant; @@ -47,9 +48,11 @@ participants.add(createHierarchyParticipant()); participants.add(new AddMappedOutputFoldersParticipant(filteredExtensions)); participants.add(FilterResourceParticipant.createSuffixFilterParticipant(filteredExtensions)); - participants.add(new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI))); participants.add(new AddClasspathLibReferencesParticipant()); participants.add(new AddClasspathFoldersParticipant()); + if (ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) { + participants.add(new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI))); + } return participants; }
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 1bc9d62..a56d067 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
@@ -37,7 +37,6 @@ import org.eclipse.jst.common.jdt.internal.javalite.JavaCoreLite; import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent; import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement; import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyVirtualComponent; import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator.ClasspathDependencyValidatorData; @@ -600,9 +599,6 @@ final IClasspathAttribute attribute = attributes[i]; final String name = attribute.getName(); if (name.equals(CLASSPATH_COMPONENT_DEPENDENCY)) { - if (!ClasspathDependencyEnablement.isAllowClasspathComponentDependency() && isLegacyJ2EE && isMappedIntoContainer(attribute.getValue())) - return null; - if (attributeType == DependencyAttributeType.DEPENDENCY_OR_NONDEPENDENCY || attributeType == DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY) { return attribute; @@ -708,5 +704,3 @@ } } - -
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 0c542ec..ac4ee4b 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
@@ -86,12 +86,7 @@ final boolean isWebApp = JavaEEProjectUtilities.isDynamicWebProject(proj); final IVirtualComponent component = ComponentCore.createComponent(proj); final boolean isLegacyJ2EE = JavaEEProjectUtilities.isLegacyJ2EEComponent(component); - if (!ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) { - if ((isLegacyJ2EE && !isWebApp) || !JavaEEProjectUtilities.usesJavaEEComponent(component)) { - return OK_STATUS; - } - } - + final IJavaProjectLite javaProjectLite = JavaCoreLite.create(proj); final Map referencedRawEntries = ClasspathDependencyUtil.getRawComponentClasspathDependencies(javaProjectLite, DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY, isLegacyJ2EE); final List potentialRawEntries = ClasspathDependencyUtil.getPotentialComponentClasspathDependencies(javaProjectLite, isLegacyJ2EE); @@ -122,12 +117,12 @@ } if (!referencedRawEntries.isEmpty()) { - if (JavaEEProjectUtilities.isApplicationClientProject(proj)) { - // classpath component dependencies are not supported for application client projects - final IMessage msg = new Message("classpathdependencyvalidator", //$NON-NLS-1$ - IMessage.HIGH_SEVERITY, AppClientProject, null, proj); - _reporter.addMessage(this, msg); - } +// if (JavaEEProjectUtilities.isApplicationClientProject(proj)) { +// // classpath component dependencies are not supported for application client projects +// final IMessage msg = new Message("classpathdependencyvalidator", //$NON-NLS-1$ +// IMessage.HIGH_SEVERITY, AppClientProject, null, proj); +// _reporter.addMessage(this, msg); +// } // are there any root mappings if (hasRootMapping && component != null) {
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/exportmodel/JavaEESingleRootCallback.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/exportmodel/JavaEESingleRootCallback.java index d94c2d1..0b98942 100644 --- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/exportmodel/JavaEESingleRootCallback.java +++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/exportmodel/JavaEESingleRootCallback.java
@@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jst.j2ee.internal.common.exportmodel; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -101,21 +102,14 @@ protected boolean hasClasspathDependencies(IVirtualComponent component) { try { - final boolean isWebApp = JavaEEProjectUtilities.isDynamicWebComponent(component); - boolean webLibsOnly = false; - if (!ClasspathDependencyEnablement.isAllowClasspathComponentDependency() && isWebApp) { - webLibsOnly = true; - } final Map entriesToAttrib = ClasspathDependencyUtil.getRawComponentClasspathDependencies( JavaCoreLite.create(component.getProject()), - DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY, - webLibsOnly); + DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY); return entriesToAttrib != null && entriesToAttrib.size() > 0; } catch( CoreException ce ) {} return false; } - private void validateWebProject(SingleRootUtil util, IVirtualComponent vc, List resourceMaps) { // Ensure there are only basic component resource mappings -- one for the content folder // and any for src folders mapped to WEB-INF/classes @@ -190,11 +184,15 @@ } public IFlattenParticipant[] getDelegateParticipants() { - return new IFlattenParticipant[] { - new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI)), - new JEEHeirarchyExportParticipant(), - FilterResourceParticipant.createSuffixFilterParticipant(filteredSuffixes) - }; + List<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>(); + + if (ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) { + participants.add(new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI))); + } + participants.add(new JEEHeirarchyExportParticipant()); + participants.add(FilterResourceParticipant.createSuffixFilterParticipant(filteredSuffixes)); + + return participants.toArray(new IFlattenParticipant[participants.size()]); }
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 48e58df..16463a6 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
@@ -56,7 +56,6 @@ import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent; import org.eclipse.jst.j2ee.internal.archive.operations.ComponentLoadStrategyImpl; import org.eclipse.jst.j2ee.internal.archive.operations.EARComponentLoadStrategyImpl; -import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement; import org.eclipse.jst.j2ee.internal.modulecore.util.JEEManifestDiscerner; import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; @@ -730,13 +729,11 @@ //createClasspathComponentDependencyElements(comp); // Add elements for raw classpath entries (either already tagged or potentially taggable) - if(ClasspathDependencyEnablement.isAllowClasspathComponentDependency()){ try { createClasspathEntryElements(component, IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH, IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_COMPONENT_PATH); } catch (CoreException ce) { J2EEPlugin.logError(ce); } - } if (earComponent != null) { Path earLibDirPath = null;
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java index 6567948..89393a4 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java +++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java
@@ -35,6 +35,7 @@ import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper; import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager; import org.eclipse.jst.j2ee.internal.J2EEConstants; +import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyEnablement; import org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant; import org.eclipse.jst.j2ee.internal.common.exportmodel.JavaEESingleRootCallback; import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; @@ -100,15 +101,19 @@ @Override protected IFlattenParticipant[] getParticipants() { - return new IFlattenParticipant[]{ - new SingleRootExportParticipant(new JavaEESingleRootCallback()), - new JEEHeirarchyExportParticipant(), - new AddClasspathLibReferencesParticipant(), - new AddClasspathFoldersParticipant(), - new AddMappedOutputFoldersParticipant(), - new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI)), - new IgnoreJavaInSourceFolderParticipant() - }; + List<IFlattenParticipant> participants = new ArrayList<IFlattenParticipant>(); + + participants.add(new SingleRootExportParticipant(new JavaEESingleRootCallback())); + participants.add(new JEEHeirarchyExportParticipant()); + participants.add(new AddClasspathLibReferencesParticipant()); + participants.add(new AddClasspathFoldersParticipant()); + participants.add(new AddMappedOutputFoldersParticipant()); + participants.add(new IgnoreJavaInSourceFolderParticipant()); + if (ClasspathDependencyEnablement.isAllowClasspathComponentDependency()) { + participants.add(new ReplaceManifestExportParticipant(new Path(J2EEConstants.MANIFEST_URI))); + } + + return participants.toArray(new IFlattenParticipant[participants.size()]); } @Override