如何从 Ant 构建文件设置 Eclipse 构建路径和类路径? [英] How do I set the Eclipse build path and class path from an Ant build file?

查看:32
本文介绍了如何从 Ant 构建文件设置 Eclipse 构建路径和类路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多关于 Ant 和 Eclipse 的讨论,但以前没有人回答似乎对我有帮助.

There's a lot of discussion about Ant and Eclipse, but no previously answered seems to help me.

事情是这样的:我正在尝试构建一个 Java 程序,该程序可以从命令行使用 Ant 成功编译.(为了进一步混淆问题,我试图编译的程序是 Ant 本身.)

Here's the deal: I am trying to build a Java program that compiles successfully with Ant from the command-line. (To confuse matters further, the program I am attempting to compile is Ant itself.)

我真正想做的是将这个项目引入 Eclipse 并让它在 Eclipse 中编译,以便正确解析类型绑定和变量绑定(来自 Eclipse JDT 的命名法).我需要这个是因为我需要对构建在 Eclipse JDT 之上的代码运行静态分析.我将 Java 项目引入 Eclipse 以便 Eclipse 构建它并解析所有绑定的正常方法是将源目录导入 Java 项目,然后告诉它使用 src/main/目录作为源目录"."

What I really want to do is to bring this project into Eclipse and have it compile in Eclipse such that the type bindings and variable bindings (nomenclature from Eclipse JDT) are correctly resolved. I need this because I need to run a static analysis on the code that is built on top of Eclipse JDT. The normal way I bring a Java project into Eclipse so that Eclipse will build it and resolve all the bindings is to just import the source directories into a Java project, and then tell it to use the src/main/ directory as a "source directory."

不幸的是,使用 Ant 执行此操作会导致构建失败并出现大量编译错误.在我看来,Ant 构建文件正确设置了类路径和构建路径(可能通过排除某些源文件)而 Eclipse 没有此信息.

Unfortunately, doing that with Ant causes the build to fail with numerous compile errors. It seems to me that the Ant build file is setting up the class path and build path correctly (possibly by excluding certain source files) and Eclipse does not have this information.

有没有办法走class path &构建路径信息嵌入在 Ant 构建文件中,并将该信息提供给 Eclipse 以放入其 .project 和 .classpath 文件?我已经尝试过,从现有的构建文件(文件"菜单中的一个选项)创建一个新项目,但这无济于事.该项目仍然存在相同的编译错误.

Is there any way to take the class path & build path information embedded in an Ant build file, and given that information to Eclipse to put in its .project and .classpath files? I've tried, creating a new project from an existing build file (an option in the File menu) but this does not help. The project still has the same compile errors.

谢谢,尼尔斯

推荐答案

我使用 ivy 来管理我的 ANT 类路径,我强烈建议学习它是如何工作的.

I use the ivy to manage my ANT classpaths, I highly recommend learning how it works.

有一个 eclipse 插件 可以管理来自 ANT 用于定义其依赖项的同一 ivy.xml 文件的 Eclipse 类路径.

There is an eclipse plugin that will manage the eclipse classpath from the same ivy.xml file that ANT uses to define it's dependencies.

这篇关于如何从 Ant 构建文件设置 Eclipse 构建路径和类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆