使用现有的 ant build.xml 文件创建一个 eclipse 项目 [英] Create a eclipse project using existing ant build.xml file

查看:29
本文介绍了使用现有的 ant build.xml 文件创建一个 eclipse 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从现有的 ant build.xml 文件在 eclipse 中创建一个项目.我收到一个找到的 javac 任务列表,并指示选择一个 javac 任务继续.我如何处理 javac 任务?

I am trying to create a project in eclipse from an existing ant build.xml file. I receive a list of javac tasks found and directed to select a single javac task to continue. How do I process the javac tasks?

推荐答案

我不建议在这个阶段采用 Ant 路线,因为它会使事情复杂化.Maven 或 Gradle 将是最终要走的路 - 但目前这超出了范围.Eclipse 不需要 ant 或 build.xml ant 相关文件!

I wouldnt recommend going the Ant route at this stage as it complicates things. Maven would be the way to go in the end, or Gradle - but that's way out of the scope at this point. Eclipse doesn't need ant or a build.xml ant related file!

在 Eclipse 中执行以下操作

In Eclipse do the following

  1. 如果您使用的是普通的旧 Java,则创建一个新的 Java 项目,如果您计划使用 J2EE,则创建一个新的 Java EE、EAR 项目,然后您将在其中创建和添加可选的新 EJB 或 WAR((WEB)动态网络项目).但是EJB 或 WAR 项目不必驻留在 EAR 中,并且 EAR 目前只能与 J2EE 应用程序服务器(如 JBoss、WebSphere 或 GlassFish)配合使用
  2. 创建项目后,将您的java源代码复制到eclipse创建的src"目录 - 您可以右键单击eclipse中的src文件夹,选择属性,然后选择资源,它会告诉您它的路径.
  3. 如果您的项目需要支持库/包(jar),那么虽然不完全推荐,但最简单的方法是创建一个lib"文件夹并将其放置在 EAR 项目父目录、EJB 项目父目录或如果你在做 J2EE,WAR 项目的父目录,如果你只是在做普通的旧 java,那么在与src"目录相同的目录级别创建 lib 文件夹.把你的罐子放在那里.
  4. Eclipse 不会立即找到这些 jar,因此:
  5. 在eclipse中右键项目选择属性
  6. 在左侧窗格中选择 java 构建路径
  7. 点击库标签
  8. 点击添加外部 jars 按钮
  9. 导航/浏览到lib"文件夹并选择所有 jars
  10. 点击应用/确定
  11. Eclipse 应该自动构建(在任何更改时),但如果不是,请单击项目"菜单并单击自动构建".有时您可能还需要清理,然后重建
  1. Create a new Java Project if you're using plain old Java, if you plan on using J2EE, then create a new Java EE, EAR project in which you would then create and add optionally a new EJB or WAR ((WEB)Dynamic Web Project). But an EJB or WAR project does not have to reside within a EAR and an EAR only will work at the moment with a J2EE Application server like JBoss, WebSphere or GlassFish
  2. Once the projects created, copy your java source code to the "src" directory that was created by eclipse - you can right click the src folder in eclipse, select properties, then resources and it will tell you the path to it.
  3. If your project requires supporting libraries/packages (jars) then the easiest thing to do though not totally recommended is to create a "lib" folder and place it in either the EAR projects parent directory, the EJB projects parent directory, or the WAR projects parent directory if you're doing J2EE, if you're just doing plain old java, then create the lib folder at the same directory level as the "src" directory. Put your jars in there.
  4. Eclipse wont immediately find those jars so:
  5. Right click the project in eclipse select properties
  6. Select java build path in left pane
  7. Click the libraries tab
  8. Click the add external jars button
  9. Navigate/browse to the "lib" folder and select all the jars
  10. Click Apply/Okay
  11. Eclipse should build automatically (on any change), but if not click the Project menu and click build automatically. Sometimes you might also have to clean, which then rebuilds

这应该是启动最小 Java 或 J2EE eclipse 项目的基本步骤.请在对此答案的评论中告诉我,如果需要,我可以修改它以更正确地反映您在做什么

This should be the basic steps on getting a minimal Java or J2EE eclipse project started. Let me know in comments to this answer and I can modify it if need be to more correctly reflect what you're doing

这篇关于使用现有的 ant build.xml 文件创建一个 eclipse 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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