使用Ant Ivy构建,我正在尝试将我的 jar 分成一个用于第三方 jar 的配置和我构建和发布的 jar 的另一个配置 . ProjectA使用第三方jar并构建一个ProjectB依赖的jar,但是当我使用Ant Ivy confs时,我无法让ProjectB检索ProjectA jar .
当我为ProjectB执行ant脚本时,它可以很好地构建ProjectA . ProjectA构建将jar发布到本地存储库 . ProjectB从公共存储库中检索必要的jar没有问题,但是当它尝试检索ProjectA jar时,它表示UNRESOLVED DEPENDENCY:testproject#ProjectA; 2.0.0:testproject#ProjectA中找不到配置; 2.0.0:'localjars' . 它来自testproject#ProjectB; 2.0.0 localjars
如果我删除对第二个配置的所有引用,localjars,并且只使用默认的一切,它工作正常 . 我真的需要把我的 jar 分成不同的混蛋 .
我已成功使用从ant脚本传递的修订值代替下面的“2.0.0”并使用$ 引用,但conf错误是相同的 .
ProjectA ivy.xml(为简洁起见,依赖于子集):
<ivy-module version="2.0">
<info organisation="testproject" module="ProjectA" revision="2.0.0" status="release" publication="20160524124555"/>
<configurations>
<conf name="default" transitive="false" visibility="public"/>
<conf name="localjars" extends="default" visibility="public"/>
</configurations>
<publications>
<artifact name="projectA-jar-2.0.0" type="jar" conf="localjars" ext="jar"/>
</publications>
<dependencies>
<dependency org="commons-beanutils" name="commons-beanutils" rev="1.7.0" conf="default->master"/>
<dependency org="commons-collections" name="commons-collections" rev="3.1" conf="default->master"/>
</dependencies>
</ivy-module>
ProjectA build.xml发布目标:
<target name="publish" depends="package"
description="--> compile test and publish this project in the local ivy repository">
<ivy:publish artifactspattern="${DEPLOY_DIR_LIB}/[artifact].[ext]"
resolver="local" pubrevision="2.0.0" status="release"
srcivypattern="${ivy.dep.file}" forcedeliver="true" overwrite="true" conf="localjars,default"/>
<echo message="project ${ant.project.name} released with version 2.0.0" />
</target>
ProjectB ivy.xml:
<ivy-module version="2.0">
<info organisation="testproject" module="ProjectB" revision="2.0.0" status="release" publication="20160524103113"/>
<configurations>
<conf name="default"/>
<conf name="localjars" extends="default"/>
</configurations>
<publications>
<artifact name="projectB-2.0.0" conf="localjars" type="jar" ext="jar"/>
</publications>
<dependencies>
<dependency org="testproject" name="ProjectA" rev="${revision}" transitive="true" conf="localjars->localjars; default->default"/>
</dependencies>
ProjectB Ant解析目标:
<target name="resolve" description="--> retrieve dependencies with ivy">
<ivy:retrieve pattern="${DEPLOY_DIR_LIB}/[artifact]-2.0.0.[ext]" revision="2.0.0" conf="localjars" />
</target>
知道什么是错的吗?谢谢!
帕特里克
1 回答
不完全确定您的配置无法正常工作的原因 . 我建议的一件事是不要禁用传递依赖 . 您会注意到我在下面的工作示例中创建“默认”配置有不同的方法 .
示例
每个项目都有自己的本地构建和常 Spring 藤文件 . 协作是通过发布到“本地”存储库的jar .
build.xml
使用buildlist任务以正确顺序构建所有模块的主构建文件 .
此外,我通常还包括安装常 Spring 藤的额外目标 .
ProjectA / ivy.xml
"master"配置仅包含工件 . 这个命名约定反映了scopes used by Maven .
另请注意“默认”配置如何扩展“主”和“运行时” . 这使客户能够下载他们需要的一切 .
ProjectB / ivy.xml
请注意ProjectA是唯一的依赖项,它将远程“默认”配置映射到本地“编译”配置 .
另一个微妙的问题是使用“latest.integration”动态修订版 . 这意味着我们不需要对ProjectA的修订进行硬编码 .
ProjectA / build.xml
要发布的修订版本设置为属性,必要时可以覆盖该属性 .
另请注意,如何使用cachepath任务将常 Spring 藤配置用于控制构建中的类路径
ProjectB / build.xml
与具有不同名称属性的其他项目相同 .