- This topic has 1 reply, 2 voices, and was last updated 18 years, 4 months ago by Riyad Kalla.
-
AuthorPosts
-
sleyzerzonParticipantHi,
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:
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/spring.related.jars"/>
consisting of (in ant lingo):
<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:
<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
Riyad KallaMemberSimeon,
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?
-
AuthorPosts