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

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

问题描述



这是交易:我正在尝试构建一个Java程序,从命令行成功编译Ant。 (为了进一步混淆,我正在尝试编译的程序是Ant本身。)



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



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



有没有办法让课程路径&构建路径信息嵌入到Ant构建文件中,并将该信息给Eclipse放入其.project和.classpath文件中?我已经尝试,从现有的构建文件(File菜单中的一个选项)创建一个新的项目,但这并没有帮助。该项目仍然有相同的编译错误。



谢谢,
Nels

解决方案

我使用常春藤管理我的ANT类路径,我强烈建议学习如何工作。



有一个 ivy.xml / em>文件,ANT用于定义它的依赖关系。


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

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.)

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."

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.

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.

Thanks, Nels

解决方案

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

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天全站免登陆