MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
sleyzerzon
Post subject: User Libraries & jar organization  PostPosted: Jul 11, 2006 - 04:51 PM
Registered Member
Registered Member


Joined: Nov 03, 2004
Posts: 36

Hi,

I have a general question on best practices of organizing dependent jars inside a project. To group jars into logical units, it's recommended to use User Libraries Eclipse construct. The question I have is: How to deal with the overlapping jars that different frameworks might introduce inside the same Java project?

For example, one might have a user library defined to group the spring-related jars into it, like so:

Code:
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/spring.related.jars"/>

consisting of (in ant lingo):

Code:
<fileset id="spring.related.jars" dir="${dir.lib}">
   <include name="${jar.spring}" />
   <include name="${jar.aopalliance}" />
   <include name="${jar.commons-logging-1.1}" />
   <include name="${jar.dom4j}" />
   <include name="${jar.commons.collections-3.0}" />
   <include name="${jar.cglib}" />
   <include name="${jar.hibernate}"/>
</fileset>


and then alongside this user library one might want to define another user library, jasper.related.jars comprised of the following jars:

Code:
<fileset id="jasperreports.related.jars" dir="${dir.lib}">
   <include name="${jar.commons-beanutils-1.6}"/>
   <include name="${jar.commons-digester-1.7}"/>
   <include name="${jar.commons.javaflow-20060411}"/>
   <include name="${jar.commons.collections-3.0}"/>
   <include name="${jar.commons-logging-1.1}"/>
   <include name="${jar.commons-logging-api-1.1}"/>
   <include name="${jar.jdt-compiler-3.1.1}" />
   <include name="${jar.jasperreports-1.2.3}" />
   <include name="${itext-1.3.1.jar}" />
</fileset>


This won't be tolerated by Eclipse and the "Build path contains duplicate entry" exception is raised. This is because commons-collections.jar and commons-logging.jar are overlapping in both user libraries.

One way would be to resort to not having User Libraries defined at all, and instead use regular variables of which only one copy will be imported into the build path of every project. But then we are loosing the benefit of clearly segregating the jars into the logical units and tracing the dependency of each framework used in the project.

Could someone give their reasoning and possible approaches/techniques?

Thanks,
Simeon
 
 View user's profile Send private message  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Jul 14, 2006 - 02:40 AM
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23824

Simeon,
Good question, I wasn't actually aware that Eclipse would complain about this as I tend to place all the JARs my project needs into the /lib dir and not use user libraries, but I can certainly see the benefit.

Anyone have any ideas?

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits