我的项目和ant4eclipse有问题。如果我运行build.xml,则会收到以下消息:

Exception in thread "main" : org.ant4eclipse.lib.core.exception.Ant4EclipseException: Exception
whilst resolving the classpath entry '[EclipseClasspathEntry: path:
org.eclipse.jst.j2ee.internal.module.container entryKind: 0 outputLocation: null exported: false]' of project 'MyProject': '

No 'jdtClassPathLibrary' defined for library entry
'org.eclipse.jst.j2ee.internal.module.container'.
To resolve this problem, please define a 'jdtClassPathLibrary'
element inside your ant build file:

ant4eclipse:jdtClassPathLibrary name="org.eclipse.jst.j2ee.internal.module.container"
fileset dir="..."/
/ant4eclipse:jdtClassPathLibrary


但是我在哪里可以找到文件?
.classpath文件只有以下条目:

classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/

最佳答案

.classpath中有一个容器条目。这是一种简写,表示“包括所有属于此容器的罐子”。组成容器的jar的定义存储在工作空间的variablesAndContainers.dat目录中的一个名为.metadata的文件中(这些定义在工作空间范围内,不限于特定项目)。

据我所知,ant4eclipse可以读取.classpath files,但不能读取variablesAndContainers.dat文件(几年前我上次使用ant4eclipse时确实如此)。这意味着,尽管它可以找到org.eclipse.jst.j2ee.internal.module.container容器中的类路径条目,但它找不到该容器的定义。

因此,无论何时使用容器,都必须以ant4eclipse:jdtClassPathLibrary元素的形式将其定义提供给ant4eclipse,就像错误消息所指出的那样:

<ant4eclipse:jdtClassPathLibrary name="org.eclipse.jst.j2ee.internal.module.container">
    <fileset dir="..."/>
</ant4eclipse:jdtClassPathLibrary>


fileset标记应定义组成容器的jar文件。

07-26 04:03