This is an incredibly silly question, I know… But I’m in the middle of converting a Java Project once built with Ant to do so with Apache Maven, instead. One of the steps I’ve read to accomplish this was to place all of the JAR’s the project needed in the pom.xml file as a dependency. Now, since I’m not entirely too familiar with this project, was there any property setting I might be able to look at to view all of the JAR dependencies clearly? I know some are in the WEB-INF\lib directory, but looking at the original build.xml file for Ant, there seems to be more than those it was trying to add. Again, I’m very new at all of these concepts, but I was just hoping for an easy way to determine what dependencies a Java Project has so that I can add them — or their Maven-equivalent — to the pom.xml file. Any suggestions?
Edit: Here’s part of what’s confusing me. When I open the WAR file for the project that I’m trying to deploy with Apache Tomcat, these are the only JAR files I can find…
images
META-INF
util
WEB-INF
> classes
> lib
> jtds-1.2.4.jar
> jw-core-web-1.2.0.jar
> web.xml
blah.jsp
blah.jsp
blah.jsp
I assume I need these two files, at least. But when I open the build.xml file, I find a section like this:
<!-- Jars listed here are added to the generated war file -->
<fileset id="bundle.jars" dir="WebRoot/WEB-INF/lib">
<include name="base.jar"/>
<include name="ldap.jar"/>
<include name="junit.jar"/>
<include name="titan.jar"/>
<include name="activation.jar"/>
<include name="javamail-1.2.jar"/>
<include name="commons-httpclient.jar"/>
</fileset>
Granted, I didn’t see any of these jars in the WAR file briefly expanded above. In addition, the JRE System Library is listed under my Package Explorer along with a list of JAR files. Now, do I need to add these to my dependency list as well? Here’s what I’ve got:
JRE System Library
> resources.jar
> rt.jar
> jsse.jar
> jce.jar
> charsets.jar
> dnsns.jar
> dns_sd.jar
> localedata.jar
> sunjce_provider.jar
If you have your project set up in Eclipse, then you should be able to view all the dependencies in the Project Explorer view. They must be on the build path in order for you compile things properly.
On the Ant side, I would assume the necessary jars for the runtime will be copied somewhere with the rest of the build. This is especially true if your project is being built into a WAR.
If nothing is being copied over, then your best bet is to hunt down all the compile-time and run-time jars by carefully scanning your build.xml. This is something you should probably be doing anyway if you’re converting it to Maven. I suppose the key parts to look for is the javac and java Ant tasks.
As a side note, as you’re creating your pom.xml and adding dependencies, keep an eye on the dependency hierarchy by opening your pom.xml in Eclipse and clicking the Dependency hierarchy tab. This will hopefully keep you from adding redundant top-level dependencies.