[391126] EAR libraries classpath container for Utility projects in lib
does not contain jars in lib
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 803e874..821631f 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * Copyright (c) 2003, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -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){
- 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){
+ 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);