[391126] EAR libraries classpath container for Utility projects in lib does not contain jars in lib
diff --git a/features/org.eclipse.jst.web_core.feature.patch/buildnotes_org.eclipse.jst.web_core.feature.patch.html b/features/org.eclipse.jst.web_core.feature.patch/buildnotes_org.eclipse.jst.web_core.feature.patch.html index c441d2d..7768010 100644 --- a/features/org.eclipse.jst.web_core.feature.patch/buildnotes_org.eclipse.jst.web_core.feature.patch.html +++ b/features/org.eclipse.jst.web_core.feature.patch/buildnotes_org.eclipse.jst.web_core.feature.patch.html
@@ -39,5 +39,6 @@ <p>Bug <a href='https://bugs.eclipse.org/388885'>388885</a>. NPE when modules of an EAR have no archive name in the .component file</p> <p>Bug <a href='https://bugs.eclipse.org/389005'>389005</a>. Inconsistency in ADD_TO_EAR property model</p> <p>Bug <a href='https://bugs.eclipse.org/389302'>389302</a>. application.xml file is corrupted after importing an EAR project</p> +<p>Bug <a href='https://bugs.eclipse.org/391126'>391126</a>. EAR libraries classpath container for Utility projects in lib does not contain jars in lib </p> </body> </html> \ No newline at end of file
diff --git a/features/org.eclipse.jst.web_core.feature.patch/feature.properties b/features/org.eclipse.jst.web_core.feature.patch/feature.properties index 5c5c10c..825c5f9 100644 --- a/features/org.eclipse.jst.web_core.feature.patch/feature.properties +++ b/features/org.eclipse.jst.web_core.feature.patch/feature.properties
@@ -53,6 +53,7 @@ Bug https://bugs.eclipse.org/388885 NPE when modules of an EAR have no archive name in the .component file\n\ Bug https://bugs.eclipse.org/389005 Inconsistency in ADD_TO_EAR property model\n\ Bug https://bugs.eclipse.org/389302 application.xml file is corrupted after importing an EAR project\n\ +Bug https://bugs.eclipse.org/391126 EAR libraries classpath container for Utility projects in lib does not contain jars in lib\n\ \n\ # "copyright" property - text of the "Feature Update Copyright" copyright=\
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java index 5e60d04..b0ddfc9 100644 --- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java +++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java
@@ -419,7 +419,7 @@ // or if it is the empty string, do nothing. if (libDir != null && libDir.trim().length() != 0) { IPath libDirPath = new Path(libDir).makeRelative(); - // check if the component itself is not in the library directory of this EAR - avoid cycles in the build patch + // check if the component itself is not in the library directory of this EAR - avoid cycles in the build path IVirtualReference ref = earComp.getReference(component.getName()); if(ref != null){ IPath refPath = ref.getRuntimePath(); @@ -433,24 +433,30 @@ } } refPath = refPath.makeRelative(); - if (!libDirPath.equals(refPath)) { - // retrieve the referenced components from the EAR - IVirtualReference[] earRefs = earComp.getReferences(); - for (IVirtualReference earRef : earRefs) { - if(earRef.getDependencyType() == IVirtualReference.DEPENDENCY_TYPE_USES){ - // check if the referenced component is in the library directory - IPath runtimePath = earRef.getRuntimePath().makeRelative(); - boolean isInLibDir = libDirPath.equals(runtimePath); - if(!isInLibDir && earRef.getArchiveName() != null){ - IPath fullPath = earRef.getRuntimePath().append(earRef.getArchiveName()); - isInLibDir = fullPath.removeLastSegments(1).makeRelative().equals(libDirPath); - } - if (isInLibDir) { - libRefs.add(earRef); - } + boolean onlyBinary = false; + // If this component is in the library directory, we will allow only binary entries to be + // added, to avoid cycles in the build path + if (libDirPath.equals(refPath)) { + onlyBinary = true; + } + // retrieve the referenced components from the EAR + IVirtualReference[] earRefs = earComp.getReferences(); + for (IVirtualReference earRef : earRefs) { + if(earRef.getDependencyType() == IVirtualReference.DEPENDENCY_TYPE_USES){ + // check if the referenced component is in the library directory + IPath runtimePath = earRef.getRuntimePath().makeRelative(); + boolean isInLibDir = libDirPath.equals(runtimePath); + if(!isInLibDir && earRef.getArchiveName() != null){ + IPath fullPath = earRef.getRuntimePath().append(earRef.getArchiveName()); + isInLibDir = fullPath.removeLastSegments(1).makeRelative().equals(libDirPath); + } + if (isInLibDir) { + if (!onlyBinary || (onlyBinary && earRef.getReferencedComponent().isBinary())) + libRefs.add(earRef); } } } + //add EAR classpath container refs try { ClasspathLibraryExpander classpathLibExpander = new ClasspathLibraryExpander(earComp);