views:

2064

answers:

3

I'm using Ivy to manage the dependencies on my project.

So far, I've specified a dependency on Hibernate and servlet-api. However, the hibernate jar itself has a lot of dependencies that aren't really needed, such as jaas and jacc.

This becomes a show-stopper because jaas and jaac are Sun libraries and therefore their licenses forbid to place them in the Maven repos, so Ivy can't find them there.

  • How do I make Ivy download Hibernate but not these two ?
  • As a bonus, if I actually needed those and downloaded their Jars from Sun, in which folder in my machine would Ivy look for them ?
+3  A: 

How do I make Ivy download Hibernate but not these two?

Ivy does this using what it calls "configurations." Your ivy.xml that represents Hibernate will need to provide different configurations to represent different use-cases for hibernate. (There is obviously some use of hibernate that does require jaas and jacc, but apparently you don't make use of that case.)

Here is the documentation on configurations. If you want to provide the ivy.xml you are using for hibernate, I can provide pointers on building configurations that will remove the specific libraries you want removed.

If I actually needed those and downloaded their Jars from Sun, in which folder in my machine would Ivy look for them?

The "directories" that ivy looks in for ivy files and artifacts are specified by the list of resolvers you are using. The list of resolvers is specified in the ivy settings file (usually named ivysettings.xml.) Typically, these aren't local directories, but remote URLs. There is; however, a local-file resolver type that will work for this.

If you do this, you will need to provide both ivy files and the artifacts (jars), each with file-names that match the resolvers patterns. Details on that are in the documentation.

Here is an example local-file resolver from an ivy settings file:

<filesystem name="myfiles" checkconsistency="false" checksums="" transactional="false">
   <ivy pattern="/data/repo/[organisation]/[module]-[revision].ivy.xml"/>
   <artifact pattern="/data/repo/[organisation]/[module]-[revision].[ext]"/>
</filesystem>

Also note that you will need to point your ivy tasks to the correct resolver. You can do this with the resolver attribute on the ant tasks, or with the defaultResolver attribute on the settings element in the ivy settings file.

Here is the documentation on resolvers.

EDIT: The OP found a less-time intensive workaround for his specific original problem. The "exclude" child-tag of the dependency tag did the job for him:

<dependencies>  
   <dependency org="org.hibernate" name="hibernate-core" rev="3.3.1.GA" conf='..'> 
       <exclude name='jaas' /> 
       <exclude name='jacc' />
   </dependency>
</dependencies>
Jared
Nice answer, thanks for your time.I discovered later the exclude tag, which so far solves my problem of excluding some libs:<dependencies> <dependency org="org.hibernate" name="hibernate-core" rev="3.3.1.GA" conf='..'><exclude name='jaas' /><exclude name='jacc' />
Leonel
+5  A: 

Another option for not downloading any dependencies is to disable them with the transitive attribute. So if you wanted hibernate-core, but none of its dependencies, you could do this:

<dependencies>  
   <dependency org="org.hibernate" name="hibernate-core"
               rev="3.3.1.GA" conf='..'
               transitive="false" /> 
</dependencies>
Jared Oberhaus
A: 

Browsing the web and blogs, I found the following ivy-settings to work at grabbing jaas/jacc and hibernate

<ivysettings>

<settings defaultResolver="chained" checkUpToDate="true" />

<resolvers>
    <chain name="chained">
        <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>

        <ibiblio name="ibiblio" m2compatible="true"/>

        <ibiblio name="jboss" root="http://repository.jboss.org/maven2/" m2compatible="true"/>

        <ibiblio name="java-net-maven1" root="http://download.java.net/maven/1" pattern="${java.net.maven.pattern}" m2compatible="false"/>

        <ibiblio name="java-net-maven2" root="http://download.java.net/maven/2/" m2compatible="true"/>

        <ibiblio name="compass" m2compatible="true" root="http://repo.compass-project.org" />

    </chain>

</resolvers>

The jboss ibibilio resolver is what did the trick at grabbing JAAS/JAAC

My ivy.xml then can then pull it in with

<ivy-module version="2.0">

<info organisation="foo" module="Bar"/>
<dependencies>

    <dependency org="com.h2database" name="h2" rev="1.2+"/>

    <dependency org="org.hibernate" name="hibernate-annotations" rev="3.4.0.GA"/>     

</dependencies>

Dan