我试图将Apache Ivy与使用Apache Ant的现有Java EE项目集成。我创建了ivy.xml,ivysettings.xml(在mvnrepo中添加了一个不存在的repo)并对现有的build.xml进行了更改。
当我运行Ivy Resolve时,我得到了以下内容:
[ivy:resolve] :: resolution report :: resolve 2642ms :: artifacts dl 49ms
[ivy:resolve] :: evicted modules:
[ivy:resolve] xml-apis#xml-apis;1.0.b2 by [xml-apis#xml-apis;1.3.04] in [default]
[ivy:resolve] commons-logging#commons-logging;1.1.1 by [commons-logging#commons-logging;1.2] in [default]
[ivy:resolve] commons-codec#commons-codec;1.6 by [commons-codec#commons-codec;1.8] in [default]
[ivy:resolve] commons-logging#commons-logging;1.1.3 by [commons-logging#commons-logging;1.2] in [default]
[ivy:resolve] org.slf4j#slf4j-api;1.6.1 by [org.slf4j#slf4j-api;1.7.7] in [default]
[ivy:resolve] xml-apis#xml-apis;1.3.04 by [xml-apis#xml-apis;1.4.01] in [default]
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 108 | 0 | 0 | 6 || 102 | 0 |
---------------------------------------------------------------------
如何解决此问题? ivy.xml中没有直接提到这些模块。这是我对常春藤的第一次实验,任何帮助都将受到高度赞赏。
<ivysettings>
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
<ibiblio name="primefaces-themes-old" m2compatible="true" root="http://repository.primefaces.org"/>
</resolvers>
<modules>
<module organisation="org.primefaces.themes" resolver="primefaces-themes-old"/>
</modules>
</ivysettings>
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="Fetching Life" module="WebApp" status="integration">
</info>
<dependencies>
<dependency org="commons-collections" name="commons-collections" rev="3.2.2" conf="default"/>
<dependency org="mysql" name="mysql-connector-java" rev="5.1.40" conf="default"/>
<dependency org="com.googlecode.flyway" name="flyway-core" rev="2.3.1" conf="default"/>
<dependency org="com.googlecode.flyway" name="flyway-ant" rev="2.3.1" conf="default"/>
<dependency org="org.hibernate" name="hibernate-core" rev="5.0.11.Final" conf="default"/>
<dependency org="org.springframework" name="spring-core" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-web" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-orm" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-context" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-context-support" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-test" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-oxm" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-webmvc" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-webmvc-portlet" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.springframework" name="spring-aspects" rev="4.2.8.RELEASE" conf="default"/>
<dependency org="org.primefaces" name="primefaces" rev="5.1" conf="default"/>
<dependency org="com.sun.faces" name="jsf-api" rev="2.1.29" conf="default"/>
<dependency org="com.sun.faces" name="jsf-impl" rev="2.1.29" conf="default"/>
<dependency org="joda-time" name="joda-time" rev="2.8.2" conf="default"/>
<dependency org="org.apache.shiro" name="shiro-all" rev="1.2.6" conf="default"/>
<dependency org="com.google.apis" name="google-api-services-calendar" rev="v3-rev179-1.19.1" conf="default"/>
<dependency org="com.google.code.gson" name="gson" rev="2.3.1" conf="default"/>
<dependency org="org.mnode.ical4j" name="ical4j" rev="1.0.7" conf="default"/>
<dependency org="net.sourceforge.jexcelapi" name="jxl" rev="2.6.12" conf="default"/>
<dependency org="javax.el" name="javax.el-api" rev="2.2.5" conf="default"/>
<dependency org="com.ocpsoft" name="prettyfaces-jsf2" rev="3.3.3" conf="default"/>
<dependency org="org.mindrot" name="jbcrypt" rev="0.3m" conf="default"/>
<dependency org="javax.jdo" name="jdo-api" rev="3.0.1" conf="default"/>
<dependency org="org.quartz-scheduler" name="quartz" rev="2.2.3" conf="default"/>
<dependency org="org.omnifaces" name="omnifaces" rev="1.6.3" conf="default"/>
<dependency org="javax.servlet.jsp.jstl" name="jstl-api" rev="1.2" conf="default"/>
<dependency org="antlr" name="antlr" rev="2.7.7" conf="default"/>
<dependency org="org.apache.james" name="apache-mime4j" rev="0.6.1" conf="default"/>
<dependency org="org.atmosphere" name="atmosphere-runtime" rev="2.2.9" conf="default"/>
<dependency org="bsh" name="bsh" rev="1.3.0" conf="default"/>
<dependency org="junit" name="junit" rev="4.12" conf="default"/>
<dependency org="org.mockito" name="mockito-all" rev="1.10.19" conf="default"/>
<dependency org="commons-fileupload" name="commons-fileupload" rev="1.2.2" conf="default"/>
<dependency org="org.apache.commons" name="commons-exec" rev="1.3" conf="default"/>
<dependency org="commons-io" name="commons-io" rev="2.4" conf="default"/>
<dependency org="commons-jxpath" name="commons-jxpath" rev="1.3" conf="default"/>
<dependency org="net.sf.ehcache" name="ehcache" rev="2.10.0" conf="default"/>
<dependency org="org.glassfish.web" name="el-impl" rev="2.2" conf="default"/>
<dependency org="net.sf.jsr107cache" name="jsr107cache" rev="1.1" conf="default"/>
<dependency org="javax.mail" name="mail" rev="1.4.7" conf="default"/>
<dependency org="io.netty" name="netty" rev="3.5.13.Final" conf="default"/>
<dependency org="org.objenesis" name="objenesis" rev="2.1" conf="default"/>
<dependency org="com.google.protobuf" name="protobuf-java" rev="2.4.1" conf="default"/>
<dependency org="xalan" name="serializer" rev="2.7.2" conf="default"/>
<dependency org="xalan" name="xalan" rev="2.7.2" conf="default"/>
<dependency org="xerces" name="xercesImpl" rev="2.11.0" conf="default"/>
<dependency org="org.primefaces.themes" name="casablanca" rev="1.0.10" conf="default"/>
<dependency org="net.sourceforge.cssparser" name="cssparser" rev="0.9.20" conf="default"/>
<dependency org="dom4j" name="dom4j" rev="1.6.1" conf="default"/>
<dependency org="org.ini4j" name="ini4j" rev="0.5.4" conf="default"/>
<dependency org="org.eclipse.jetty" name="jetty-websocket" rev="8.1.22.v20160922" conf="default"/>
<dependency org="org.w3c.css" name="sac" rev="1.3" conf="default"/>
</dependencies>
</ivy-module>
<project name="SampleApp" default="usage" basedir="." xmlns:flyway="antlib:com.googlecode.flyway.ant" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="lib.dir" value="${basedir}/${web.dir}/WEB-INF/lib/"></property>
<target name="resolve" description="resolve dependencies with ivy">
<ivy:resolve conf="default"/>
</target>
<target name="cleancache" description="Purge ivy cache">
<ivy:cleancache/>
</target>
<target name="dependencytree" depends="resolve" description="Show dependency tree">
<ivy:dependencytree />
</target>
<target name="retrieve" depends="resolve" description="Resolve and Retrieve with ivy">
<ivy:retrieve conf="default" sync="true" type="jar,bundle" pattern="${lib.dir}[artifact]-[revision].[ext]"/>
<!-- <ivy:cachepath pathid="default.classpath" /> -->
</target>
</project>
答案 0 :(得分:6)
如果在关闭依赖项标记之前添加行<conflict manager="all"/>
,则表示您不会拥有任何已驱逐的模块。像这样
<conflict manager="all"/>
</dependencies>
从here引用内置冲突管理器all
:
此冲突管理器通过选择所有修订来解决冲突。 也称为NoConflictManager,它不会驱逐任何模块。
我必须把conflict
放在最后,否则它不会起作用。好像是a bug in ivy。
请确保这是您想要的。引自here:
在解决冲突期间优化了两件事:下载 工件和常春藤文件的下载。第一个始终是由 常春藤,即被驱逐模块的文物永远不会被下载。该 第二个不是那么简单,因为知道是什么 冲突常春藤需要知道依赖图,并知道 依赖图,它必须下载常春藤文件。但是常春藤很高兴 对此进行了优化,并试图尽快驱逐模块 可能。这就是为什么依赖关系的顺序很重要的原因 下载优化。事实上,常春藤遍历依赖图 依赖项在常春藤文件中声明的顺序,以及 每次遇到对模块的依赖时,首先检查是否 这个模块存在冲突,如果是这种情况,它会问 冲突经理解决冲突。然后,如果模块是 被驱逐,它不下载它的常春藤文件,整个分支是 没有经过,这可以节省很多时间。
答案 1 :(得分:2)
只需添加一些内容即可。
冲突部分工作正常。
<conflict manager="all"/>
无论如何,要找到有关它的信息并不容易,知道它的用法可以限制为单个依赖项,或者还使用通配符来选择它们的子集可能会很有用。就我而言,我是这样使用的:
<conflict manager="all" module="module_1" org="org_1"/>
此外,还可以选择使用不同的经理选择不同的策略,有关更多信息,请访问:http://ant.apache.org/ivy/history/2.0.0/settings/conflict-managers.html