Ivy appears to fetch javadoc jars only

后端 未结 1 458
青春惊慌失措
青春惊慌失措 2021-01-03 05:00

I\'m using Ivy on my project, with the Ivy Eclipse plugin.

It appears that certain jars which are downloaded and added to my project are the javadoc jars, not the ja

相关标签:
1条回答
  • 2021-01-03 05:55

    Some open source modules include optional java doc jars. To remove them add a configuration mapping to each of your dependencies:

       <dependency org="junit" name="junit" rev="4.8.2" conf="default"/>
    

    The default configuration in ivy is equivalent to the the compile scope in a maven module. This is how the optional libraries can be automatically omitted. (Check their POMs).

    A better approach is to declare your own configurations and the default mapping as follows:

    <configurations defaultconfmapping="compile->default">
       <conf name="compile" description="Required to compile code"/>
       <conf name="test" description="Additional test dependencies" extends="compile" />
    </configurations>
    

    Then in your ivy file you only need to declare the non-standard configurations:

    <dependencies>
        <dependency org="org.hamcrest" name="hamcrest-library" rev="1.3.RC2" conf="test->default"/>
        <dependency org="junit" name="junit" rev="4.8.2" conf="test->default"/>
        <dependency org="org.mockito" name="mockito-core" rev="1.8.5" conf="test->default"/>
        <dependency org="javax.persistence" name="persistence-api" rev="1.0"/>
    </dependencies>
    

    In this case we only want the 3 test libraries to appear on the test configuration.

    Still confused? The magic of ivy configurations is when you use them to manage your build's class path

      <target name='dependencies' description='Resolve project dependencies and set classpaths'>
        <ivy:resolve/>
    
        <ivy:cachepath pathid="compile.path"  conf="compile"/>
        <ivy:cachepath pathid="test.path"     conf="test"/>
      </target>
    

    This is what Maven is doing when you declare a scope tag on a dependency, for example:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
    

    The scopes in Maven are fixed. In ivy you can have as many as you need.

    0 讨论(0)
提交回复
热议问题