将 eclipse 项目 .classpath 依赖项提取到 ant 脚本中
我有一个 Eclipse 项目列表,我想根据现有项目配置对其进行编译。
据我所知,如果 ant 脚本可以读取 .classpath 文件,它几乎能够推断项目依赖项并以正确的顺序执行“javac”编译。这将节省在 ant 脚本或 Makefile 中再次描述相同依赖项的时间。
我感兴趣的依赖项是 JAR 依赖项、JRE 依赖项和项目间依赖项。据我所知,这些是 .classpath XML 文件的一部分。
关于如何在 ant 脚本中使用 Eclipse 项目依赖项有什么想法吗?
I have a list of Eclipse projects that I would like to compile based on the existing project configuration.
As far as I can tell, if an ant script could read the .classpath files, it would pretty much be able to infer the project dependencies and perform a "javac" compilation in the right order. This would save time in describing the same dependencies again in the ant script or a Makefile.
The dependencies I am interested in are JAR Dependencies, JRE dependencies, and inter-project dependencies. These are -- as far as I can tell -- part of the .classpath XML file.
Any ideas on how Eclipse project dependencies could used in an ant script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
右键单击您的项目 ->出口
“常规/Ant 构建文件”。
选择项目即可。
否则...
我对ant4eclipse有一些经验,但要让它稳定起来很麻烦。
去检查 Buckminster 或 Maven Tycho 以获得好的解决方案。
Right click on your Project -> Export
"General/Ant Buildfiles".
Choose the projects and there you go.
Otherwise...
I have some experience with ant4eclipse and it is a hassle to get it stable.
Go check Buckminster or Maven Tycho for a good solution.
我目前正在使用 Ivy 以及 Ant、Eclipse 和 Maven。
我就是喜欢常春藤的工作方式。
目前,我们的工作区中有许多项目,前端使用 Liferay(带有 Tomcat),后端使用 Glassfish。
我们正在寻找一种比我们现在做的更好的方法来管理我们的依赖关系。
因此,我采用了 Ivy,替换了 Eclipse 中的所有类路径和部署依赖项,并且能够使用 Eclipse 或 Ant 为每个项目使用 1 个 ivy 文件来构建我的应用程序。
Ivy 的集成就像 Ant 中的魅力一样,构建可以从工作区或通过命令行完成。
我强烈建议你看看这条大道。此外,通过添加 Artifactory,我们有一个本地存储库,ivy 文件在其中查找依赖项。这有助于我们维护和规则开发人员要使用哪些 jar。一旦一切设置完毕,我们将使用 Jenkins 每晚构建我们的应用程序,并且这些构建将使用我们的 Artifactory 存储库来解决依赖关系,因为我们的构建服务器无法访问互联网。
希望这有帮助
I'm currently using Ivy along with Ant, Eclipse and Maven.
I just love the way Ivy works.
Currently, we have a workspace with many projects using Liferay (with Tomcat) for the front-end and Glassfish for the back-end.
We were looking for a way to manage our dependencies a lot better than how we were doing it.
So I took Ivy, replaced all of the classpaths and deployment dependencies in eclipse and was able to build my application using 1 ivy file per project using either Eclipse or Ant.
Ivy integrates like a charm in ant and builds are done either from the workspace or by command line.
I strongly suggest you look at this avenue. Additionnaly, by adding Artifactory, we have a local repository in which the ivy files look for dependencies. This helps us maintain and rule which jars are to be used by developpers. Once everything is setup, we will build our application nightly using Jenkins and these builds will be using our Artifactory repository to resolve dependencies since our build servers do not have access to the internet.
Hope this helped
如果您仅使用“外部工具配置”从 eclipse 运行 Ant 脚本,则可以将变量 ${project_classpath} 添加到类路径。
根据您是否在插件项目和依赖项中,您可能需要添加
${eclipse_home}。
如果启动
变量引用空选择:${project_classpath}
时出错,请确保选择了 ant xml 文件或至少选择了项目。这很重要。If you are running the Ant script only from eclipse using the "External Tools Configurations", you can add the variable ${project_classpath} to the Classpath.
Depending on if you are in a plugin project and dependencies you might need to add the
${eclipse_home}.
In case you get an error launching
Variable references empty selection: ${project_classpath}
, make sure the ant xml file or at least the project is selected. This is important.我相信 ant4eclipse 项目提供了对基于 Eclipse 元数据文件执行 Ant 构建的支持。
然而,在我看来,这就是把事情从后往前做。您不应该根据您的 IDE (Eclipse) 环境来构建 (Ant)。但如果您可以从 Ant 构建中派生 Eclipse 环境,那么它会很有用。
这是我工作的团队中成功使用的方法。我们有一个辅助 Ant 目标,它将 XLST 应用于项目
build.xml
文件,以将它们转换为 Eclipse.classpath
文件。因此,Antbuild.xml
文件是我们项目的单一配置点。I believe the ant4eclipse project provides support for executing Ant builds based on Eclipse metadata files.
However, in my opinion that is doing things back to front. You shouldn't have your build (Ant) depending on your IDE (Eclipse) environment. But it is useful if you can derive your Eclipse environment from your Ant build.
This is an approach used successfully in a team I worked in. We had a helper Ant target which applied XLST to project
build.xml
files to transform these into Eclipse.classpath
files. Thus the Antbuild.xml
files were the single configuration point for our projects.