我想从模块的jar工件中单独发布模块的依赖项.
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info organisation="com.mycompany" module="platform" />
<configurations defaultconfmapping="release->*;compile->*" defaultconf="release">
<conf name="release" />
<conf name="compile" extends="release" />
</configurations>
<publications>
<artifact name="platform-api" type="jar" ext="jar" />
</publications>
<dependencies>
<dependency org="com.google.inject" name="guice" rev="3.0" />
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.6" />
<dependency org="com.google.guava" name="guava" rev="13.0-rc1" conf="compile" />
<dependency org="log4j" name="log4j" rev="1.2.17" conf="compile" />
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.6" conf="compile" />
</dependencies>
</ivy-module>
Run Code Online (Sandbox Code Playgroud)
对于上面的配置,我想要一个仅包含guice和slf4j-api jar的工件,没有platform-api.jar.我目前的解决方案是在依赖模块中定义两个依赖项,一个是传递的,另一个不是:
<dependency org="com.mycompany" name="platform" rev="1.0-SNAPSHOT" conf="myconf->release">
<exclude org="com.mycompany" />
</dependency>
<dependency org="com.mycompany" name="platform" rev="1.0-SNAPSHOT" transitive="false" conf="myotherconf->release" />
Run Code Online (Sandbox Code Playgroud)
但是当第三个模块依赖于这两个模块时,这个解决方案会导致问题,而且它只是丑陋.
试试这个:
<ivy-module version="2.0">
<info organisation="com.mycompany" module="platform" />
<configurations>
<conf name="default" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
<conf name="master" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
<conf name="compile" description="Compile dependencies"/>
<conf name="runtime" description="Runtime dependencies, includes compile dependencies" extends="compile"/>
</configurations>
<publications>
<artifact name="platform-api" type="jar" ext="jar" conf="master"/>
</publications>
<dependencies>
<!-- Compile dependencies -->
<dependency org="com.google.inject" name="guice" rev="3.0" conf="compile->default"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.6" conf="compile->default"/>
<dependency org="com.google.guava" name="guava" rev="13.0-rc1" conf="compile->default" />
<!-- Runtime dependencies -->
<dependency org="log4j" name="log4j" rev="1.2.17" conf="runtime->default" />
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.6" conf="runtime->default" />
</dependencies>
</ivy-module>
Run Code Online (Sandbox Code Playgroud)
笔记:
既然您的模块具有针对已发布工件的单独配置以及它的运行时依赖性,则可以使用单个依赖性声明将这些配置映射到单独的本地配置:
<dependency org="com.mycompany" name="platform" rev="1.0-SNAPSHOT" conf="myconf->runtime;myotherconf->master" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
589 次 |
| 最近记录: |