我相信我们的配置与您尝试设置的配置类似。确保在 Preferences > Ivy > Classpath 窗格中选中了“Resolve dependencies in workspace”。
使用下面的设置,将 WarProject 添加到 Tomcat 时,您应该会在 WarProject 节点上看到一个 [+] 链接,展开它应该会显示 JarProject 节点。发布时,您应该会看到JarProject.jar
其中定义的任何 jar 都已ivy.xml
添加到wtpwebapps/WarProject/WEB-INF/lib
Tomcat 的发布目录中,对我而言,该目录位于.metadata/.plugins/org.eclipse.wst.server.core/tmp0
我的工作区目录下。
Jar 项目的 .settings/org.eclipse.wst.common.project.facet.core.xml:
<faceted-project>
<fixed facet="jst.java" />
<fixed facet="jst.utility" />
<installed facet="jst.java" version="1.6" />
<installed facet="jst.utility" version="1.0" />
</faceted-project>
Jar 项目的 .settings/org.eclipse.wst.common.component:
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="JarProject">
<wb-resource deploy-path="/" source-path="/src" />
<wb-resource deploy-path="/" source-path="/resources" />
</wb-module>
</project-modules>
Jar 项目的 ivy.xml:
<ivy-module
version="2.0"
xmlns:m="http://ant.apache.org/ivy/maven"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info module="JarProject" organisation="org.whatever" revision="${revision}" />
<configurations>
<conf name="local" visibility="private"
description="Artifacts necessary for local development and testing" />
<conf name="master" />
<conf name="sources" />
</configurations>
<publications>
<artifact ext="pom" type="pom" />
<artifact ext="jar" type="jar" conf="master" />
<artifact ext="jar" type="source" conf="sources" m:classifier="sources" />
</publications>
<dependencies defaultconfmapping="*->master(default),runtime()">
<dependency org="org.jdom" name="jdom" rev="1.0" conf="master" />
<dependency org="junit" name="junit-dep" rev="4.9" conf="local" />
</dependencies>
</ivy-module>
War项目的.settings/org.eclipse.wst.common.project.facet.core.xml:
<faceted-project>
<fixed facet="jst.java" />
<fixed facet="jst.web" />
<installed facet="jst.java" version="1.6" />
<installed facet="jst.web" version="2.5" />
<runtime name="Apache Tomcat v6.0" />
War项目的.settings/org.eclipse.wst.common.component:
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="WarProject">
<property name="context-root" value="WarProject" />
<wb-resource deploy-path="/" source-path="/WebContent" />
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src" />
<wb-resource deploy-path="/WEB-INF/classes" source-path="/resources" />
</wb-module>
</project-modules>
War项目的.classpath:
<classpath>
<classpathentry kind="output" path="bin" />
<classpathentry kind="src" path="src" />
<classpathentry kind="src" path="resources" />
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="owner.project.facets" value="jst.java" />
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web" />
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&confs=local&ivySettingsPath=%24%7Bworkspace_loc%3AWarProject%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=" />
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&confs=master&ivySettingsPath=%24%7Bworkspace_loc%3AWarProject%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib" />
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container" />
</classpath>
War项目的ivy.xml:
<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 module="WarProject" organisation="org.whatever" revision="${revision}" />
<configurations>
<conf name="local" visibility="private"
description="Artifacts necessary for local development and testing" />
<conf name="master" />
</configurations>
<dependencies defaultconfmapping="*->master(default),runtime()">
<dependency org="org.whatever" name="JarProject" rev="latest.integration" changing="true" conf="master" />
<!-- and other dependencies of the war project -->
</dependencies>
</ivy-module>
我还发现可以省略org.eclipse.jst.component.dependency
Ivy 类路径容器的类路径条目中的属性,而是将其添加到org.eclipse.wst.common.component
文件中,如下所示:
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/con/org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?ivyXmlPath=ivy.xml&confs=master&ivySettingsPath=%24%7Bworkspace_loc%3AWarProject%2Fivysettings.xml%7D&loadSettingsOnDemand=false&propertyFiles=">
<dependency-type>consumes</dependency-type>
</dependent-module>
但是在这种替代方案下,如果我更改 ivy.xml 并运行解析,部署的 webapp 并不会很好地更新。此外,对 Ivy 的 URL 参数的任何更改都需要与这两个文件保持同步,否则不会对部署程序集做出任何贡献。
不知道如何通过 UI 设置所有这些...