导出/导入 Eclipse 构建路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1306885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
export/import Eclipse build path
提问by Jason S
I like Eclipse's build path features, but would like to keep it in sync with my ant build.xml
. Is there a way to either automatically import the Eclipse build path from a text file, or export the Eclipse build path to a text file, so I can use that file from ant? (if I can get to a text file, I know I can figure out how to get ant to use that file as its javac build path)
我喜欢 Eclipse 的构建路径功能,但想让它与我的 ant 保持同步build.xml
。有没有办法从文本文件中自动导入 Eclipse 构建路径,或者将 Eclipse 构建路径导出到文本文件,以便我可以从 ant 中使用该文件?(如果我可以访问文本文件,我知道我可以弄清楚如何让 ant 使用该文件作为其 javac 构建路径)
采纳答案by rodrigoap
Is there a way to either automatically import the Eclipse build path from a text file, or export the Eclipse build path to a text file, so I can use that file from ant?
有没有办法从文本文件自动导入 Eclipse 构建路径,或者将 Eclipse 构建路径导出到文本文件,以便我可以从 ant 使用该文件?
The Eclipse build path already is a text file (.classpath):
Eclipse 构建路径已经是一个文本文件 (.classpath):
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/ojdbc14_g.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="classes"/>
</classpath>
回答by VonC
Maybe ant4eclipseis the tool (plugin) you need.
也许ant4eclipse是您需要的工具(插件)。
(source: sourceforge.net)
(来源:sourceforge.net)
The aim of the
ant4eclipse
project is to avoid (or at least: to reduce) the redundancy of Eclipse and Ant configurations.
More precisely: it consists of Ant tasks that are able to read and work with some of Eclipse's configuration files. With these tasks you're able to:
- Setup classpathes as defined in Eclipse' .classpath-file
- checkout complete workspaces as it's possible with the Team Project Set feature of eclipse
- run your Java applications as you have defined them in an Eclipse Launch Configuration
With all these tasks you're able to create a complete automatic build system that starts with checking out all required projects from CVS, builds all projects in the correct order with classpath settings as specified in Eclipse, and to launch your applications as they are specified in Eclipse.
And the best of it: if you or someone else changes a configuration in Eclipse, those changes are immediately visible to your buildfiles - without changing one line of code!
该
ant4eclipse
项目的目标是避免(或至少:减少)Eclipse 和Ant 配置的冗余。
更准确地说:它由能够读取和处理某些 Eclipse 配置文件的Ant 任务组成。通过这些任务,您可以:
- 设置 Eclipse' .classpath-file 中定义的类路径
- 使用 eclipse 的 Team Project Set 功能签出完整的工作区
- 运行您在 Eclipse 启动配置中定义的 Java 应用程序
通过所有这些任务,您可以创建一个完整的自动构建系统,该系统首先从 CVS 检出所有必需的项目,使用 Eclipse 中指定的类路径设置以正确的顺序构建所有项目,并按照指定的方式启动您的应用程序在 Eclipse 中。
最棒的是:如果您或其他人更改了 Eclipse 中的配置,这些更改将立即对您的构建文件可见 - 无需更改一行代码!
回答by Jeff Walker
Starting with Eclipse 3.4 (I think) you can "export" a project into ant files. Choose "Export..." by right clicking on a project. Under "General" is "Ant Buildfiles". It generates an ant file that you could use to recompile the entire project.
从 Eclipse 3.4(我认为)开始,您可以将项目“导出”到 ant 文件中。通过右键单击项目选择“导出...”。在“常规”下是“Ant Buildfiles”。它会生成一个 ant 文件,您可以使用该文件重新编译整个项目。
回答by Michael Wiles
Just put all your jars in a well known location and in the ant build just add all those jars.
只需将所有罐子放在众所周知的位置,然后在 ant build 中添加所有这些罐子。
Then configure eclipse specifically in terms of the jars it requires. I want eclipse to be specific about the jars it requires, because I'm concerned about compile time, but with ant it's less of a concern - it's normally a fire and forget build.
然后根据它需要的 jar 专门配置 eclipse。我希望 eclipse 能够具体说明它需要的 jars,因为我担心编译时间,但是对于 ant,它不是那么重要——它通常是一个火灾而忘记构建。