Java 如何将现有的 Ant build.xml 导入 IntelliJ IDEA

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30402843/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 09:33:35  来源:igfitidea点击:

How to import existing Ant build.xml into IntelliJ IDEA

javaantintellij-ideabuild.xml

提问by Mike S

I have an existing project that uses an Ant build.xmlfile to maintain the location of dependency jars.

我有一个现有项目,该项目使用 Antbuild.xml文件来维护依赖项 jar 的位置。

In Eclipse it's very easy to import from an existing Ant file. I have searched online and looked through all of the "new project" options in IntelliJ but cannot figure out how to do this.

在 Eclipse 中,很容易从现有 Ant 文件导入。我已经在线搜索并查看了 IntelliJ 中的所有“新项目”选项,但无法弄清楚如何执行此操作。

The closest thing I've done is File> New> Project from Existing Sources. But my whole project is full of errors because it didn't use the build.xmlto include the jars.

我做过的最接近的事情是File> New> Project from Existing Sources。但是我的整个项目充满了错误,因为它没有使用build.xml来包含 jars。

回答by hitz

Intellij supports Ant projects via built in Ant plugin which is included by default in IDE. To check if it is enabled go to Settings > Plugins > Ant

Intellij 通过内置的 Ant 插件支持 Ant 项目,该插件默认包含在 IDE 中。要检查它是否已启用,请转到Settings > Plugins > Ant

After enabling plugin, you can use build.xmlfrom View > Tool Windows > Ant Build

启用插件后,您可以使用build.xmlfromView > Tool Windows > Ant Build

You should then have option(+) of importing your build.xmlfile.

然后你应该有选项(+)导入你的build.xml文件。

回答by Amir Razmjou

You should use File > New > Moduleinstead of File > New > Project from Existing Sourcesfor Ant project. You also need to set your Content rootand Module file locationto your current Ant project directory.

您应该使用File > New > Module而不是File > New > Project from Existing Sourcesfor Ant 项目。您还需要将内容根目录模块文件位置设置为当前的 Ant 项目目录。

You may also need to set right path to project output in Project Structure > Use module compile output pathand set proper content route in Project Structure > Sources

您可能还需要在Project Structure > Use module compile output path 中设置项目输出的正确路径,并在Project Structure > Sources 中设置适当的内容路径

回答by matanster

Import the project "from existing sources" without choosing any build tool (ant is not on the list, only maven, sbt, etc...). Then after completing the import wizard, in the project files view, right click ant's build.xml file, and choose the option relating to ant which is hiding at the bottom of the menu.

在不选择任何构建工具的情况下“从现有源”导入项目(ant 不在列表中,只有 maven、sbt 等...)。然后完成导入向导后,在项目文件视图中,右键单击ant的build.xml文件,选择隐藏在菜单底部的与ant相关的选项。