So its been a while since I did any Java development at home and having done enough at work I figured I would get a basic ivy setup with all the regular dependencies that I use for 90% of the projects I do at the firm and am likely to do at home so I can just copy and paste in the future. So feel free to… copy and paste!
I’m using Eclipse 3.5 with the IvyDE plugin. With those installed I created a new Java Project and then set about creating my ivy.xml. My projects pretty much all have the same basic dependencies
- Spring (3.0.3.RELEASE since that’s the latest)
- Hibernate (3.5.3.Final)
- Hibernate-search (Makes indexing my model nice and easy)
- Jodatime (Awesome for date manipulation)
- Jodatime-hibernate
- H2 database (I always start of with a mock in-memory at start of dev and then use some JPA magic to dump out a schema to DB2 or Sybase, or whatever else DB is in use)
- SLF4J (My logging api of choice)
- Jackson (For any restful services I might write)
Here’s my ivy.xml
< ?xml version="1.0" encoding="UTF-8"?> < ?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?> <ivy -module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd" version="1.3"> <info organisation="mattgoldspink" module="gtdtd" revision="1.0.0" status="integration"> <license name="Apache 2.0" url="http://www.apache.org/licenses/LICENSE-2.0"/> </info> <configurations> <conf name="compile" visibility="public" description="Maven compile dependencies"/> <conf name="runtime" visibility="public" extends="compile" description="Runtime dependencies"/> <conf name="test" visibility="private" description="Test dependencies"/> </configurations> <dependencies> <dependency org="org.springframework" name="org.springframework.spring-library" rev="3.0.3.RELEASE" conf="runtime->runtime" /> </dependency><dependency org="org.hibernate" name="hibernate-core" rev="3.5.3-Final" conf="runtime->*" /> </dependency><dependency org="com.h2database" name="h2" rev="1.2.137" conf="runtime->*" /> </dependency><dependency org="org.hibernate" name="hibernate-validator" rev="4.0.2.GA" conf="runtime->*" > <exclude org="org.slf4j" name="slf4j-log4j12" /> </dependency> <dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.5.3-Final" conf="runtime->*" /> </dependency><dependency org="org.hibernate" name="hibernate-search" rev="3.2.0.Final" conf="runtime->*"> <exclude org="javax.jms" name="jms" /> </dependency> <dependency org="joda-time" name="joda-time" rev="1.6" conf="runtime->*" /> </dependency><dependency org="org.hibernate.javax.persistence" name="hibernate-jpa-2.0-api" rev="1.0.0.Final" conf="runtime->*" /> </dependency><dependency org="joda-time" name="joda-time-hibernate" rev="1.2" conf="runtime->*"> <exclude org="org.hibernate" name="hibernate" /> </dependency> <dependency org="org.slf4j" name="slf4j-api" rev="1.5.6" conf="runtime" force="true"/> <dependency org="org.slf4j" name="slf4j-log4j12" rev="1.5.6" conf="runtime" force="true"/> <dependency org="org.codehaus.jackson" name="jackson-core-lgpl" rev="1.5.3" conf="runtime" /> <dependency org="org.codehaus.jackson" name="jackson-mapper-lgpl" rev="1.5.3" conf="runtime->*" /> </dependency></dependencies> </ivy>
I’m going to get my spring dependencies from Springsource’s ivy/maven repository, but everything else will come from a mix of JBoss and Maven2 repo’s. Here’s the ivy-settings.xml
< ?xml version="1.0" encoding="ISO-8859-1"?> <ivysettings> <caches artifactPattern="[organisation]/[module]/[revision]/[artifact].[ext]" /> <settings defaultResolver="ibiblio.jboss.java-net.springsource" checkUpToDate="true" /> <resolvers> <chain name="ibiblio.jboss.java-net.springsource"> <ibiblio name="ibiblio" m2compatible="true" /> <ibiblio name="jboss" m2compatible="true" root="https://repository.jboss.org/nexus/content/groups/public-jboss" /> <ibiblio name="java.net" m2compatible="true" root="https://repository.jboss.org/nexus/content/repositories/java.net-m2/" /> <ibiblio name="java.net" m2compatible="true" root="http://repository.codehaus.org/" /> <url name="com.springsource.repository.libraries.release"> <ivy pattern="http://repository.springsource.com/ivy/libraries/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> <artifact pattern="http://repository.springsource.com/ivy/libraries/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> <url name="com.springsource.repository.libraries.external"> <ivy pattern="http://repository.springsource.com/ivy/libraries/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> <artifact pattern="http://repository.springsource.com/ivy/libraries/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> <url name="com.springsource.repository.bundles.release"> <ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> <artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> <url name="com.springsource.repository.bundles.external"> <ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> <artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> </chain> </resolvers> </ivysettings>
After plugging the above into Eclipse and setting up my IvyDE classpath container to use the new ivy-settings.xml file there was one more thing to do which was to tell IvyDE what type the source jars were. Go to “Window” -> “Preferences”, find “Ivy” -> “Classpath” in the tree and on that page under the option for “Source types” enter “source,src,srcs”. Save and you should get source code attachment to the jars too. Note that you can tell your Eclipse project to use the ivy-settings within it by going right clicking on your Ivy classpath container and under “Ivy Settings Path” enter project:///ivy-settings.xml
Posted in
Tags:






