0

Using apache ivy I want to download jcs 1.3 jar file but I don't want rest of the transient dependencies which comes with it. Is there anyway I can specify ivy to exclude all transient dependencies for this particular dependency element? Or at least use wildcard in the exclusion pattern?

I have looked for Ivy documentation and couldn't find any example on how to use matcher for glob/regex pattern for excluding files.

Following is the snippet of my ivy.xml and I want to avoid long list of excluded name/modules.

    <dependency org="jcs" name="jcs" rev="1.3" conf="*->*,!sources,!javadoc">
        <exclude name='ant-optional' />
        <exclude name='avalon-framework' />
        <exclude name='berkeleydb' />
        <exclude name='commons-beanutils' />
        <exclude name='commons-beanutils-core' />
        <exclude name='commons-codec' />
        <exclude name='commons-collections' />
        <exclude name='commons-configuration' />
        <exclude name='commons-dbcp' />
        <exclude name='commons-digester' />
        <exclude name='commons-jxpath' />
        <exclude name='commons-lang' />
        <exclude name='commons-logging' />
        <exclude name='commons-logging-api' />
        <exclude name='commons-pool' />
        <exclude name='concurrent' />
        <exclude name='hsqldb' />
        <exclude name='jdom' />
        <exclude name='junit' />
        <exclude name='jdbc-stdext' />
        <exclude name='jta' />          
        <exclude name='log4j' />
        <exclude name='logkit' />
        <exclude name='mysql-connector-java' />
        <exclude name='oro' />
        <exclude name='servlet-api' />
        <exclude name='tomcat-util' />
        <exclude name='velocity' />
        <exclude name='xerces' />
        <exclude name='xercesImpl' />
        <exclude name='xmlrpc' />
    </dependency>
Hemant
  • 4,537
  • 8
  • 41
  • 43

1 Answers1

1

It's actually a lot simpler, using configuration mappings. Here's the example:

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="compile" description="Required to compile application"/>
        <conf name="runtime" description="Additional run-time dependencies" extends="compile"/>
        <conf name="test"    description="Required for test only" extends="runtime"/>
    </configurations>

    <dependencies>
        <!-- compile dependencies -->
        <dependency org="jcs" name="jcs" rev="1.3" conf="compile->master"/>

    </dependencies>

</ivy-module>

The magic bit is the following mapping:

compile->master

The following answer explains in more detail how ivy interprets Maven modules:

How are maven scopes mapped to ivy configurations by ivy

master contains only the artifact published by this module itself, with no transitive dependencies

Additional

Using configurations is a powerful feature. The cachepath task can be used to populate ANT paths:

   <ivy:cachepath pathid="compile.path" conf="compile"/>
   <ivy:cachepath pathid="test.path"    conf="test"/>
Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • How about using conf="*->master" in dependency instead of any other change? As I found even that solved problem here. – Hemant Jan 08 '15 at 21:46
  • @Hemant Yup that works too. As explained the remote 'master' config contains the artifact without dependencies. '*' means mapping this to all local configurations. One last point. In my configurations I use 'extends' to indicate that stuff on 'compile' is also included in both 'runtime' and 'test'. This reflects the manner in which my classpaths work in my build files. – Mark O'Connor Jan 08 '15 at 21:51