1

我有一个 ANT 项目(ant 1.8.4),可以用命令行很好地构建。我需要将这个 ant 构建文件放入 eclipse 项目中。我在这个网站上搜索了 ant-1.8.4 作为 Eclipse 项目,但我最终遇到了大约 1K 的构建错误。

问题是我必须在构建路径中添加许多 jar 文件。我需要 log4j、common-io 等等。

有没有办法解决这个jar文件问题?ant 构建代码没有问题的事实意味着所有必要的 jar 文件都被找到并自动与 ant 链接。让 eclipse 找到所有必要的 jar 文件可能需要什么步骤?

4

1 回答 1

0

Eclipse doesn't use your Ant file for building. Instead, you have to tell it the jars used and where the source is located. It will then use that information to compile the source.

I'm not a developers, so I am not 100% sure what happens if you have a really funky project where you don't want to compile all the source, or first have to process it, or manipulate the classpath as you compile. However, 90% of Java projects are fairly straight forward when it comes to at least compiling the code: My source is here, the dependent jars are here. Please compile.

Of the other 10%, 9.8% usually are using things like WSDL or Ivy, but Eclipse has plugins for these. You need to download the plugins and configure them, but once this is done, Eclipse can work without needing the build.xml file to figure out how to compile the code.

It's the last 0.2% that are the killers. However, you can always tell Eclipse to spawn an Ant build using the build.xml file. Then, you need to tell Eclipse where the classfiles are located and the jars (and other resources that might not be in the *.class file directory, and you can still use the Eclipse debugger.

于 2013-02-18T21:16:49.147 回答