简体   繁体   English

以编程方式创建intellij项目和模块

[英]create intellij project and modules programmatically

I have a large project with many large directory structure. 我有一个包含许多大型目录结构的大型项目。 They produce around 90 JARs. 他们生产大约90个JAR。 The IntelliJ project structure is not the same (or similar) to the one seen by Ant scripts. IntelliJ项目结构与Ant脚本看到的结构不同(或类似)。 This creates a lot of problems while editing the code. 这在编辑代码时会产生很多问题。 Main side effect is incorrect dependencies get added. 主要的副作用是添加不正确的依赖项。 Essentially I am looking to create a one-jar one-module mapping 基本上我正在寻找创建一个jar的单模块映射

Is it possible to create Intellij modules programmatically? 是否可以通过编程方式创建Intellij模块? I can re-use existing set of libraries, created in IntelliJ 我可以重用在IntelliJ中创建的现有库集

Please consider using Maven or Gradle instead, IDEA supports both. 请考虑使用Maven或Gradle,IDEA支持两者。 Maven support is more mature, Gradle support will improve in the future updates. Maven支持更加成熟,Gradle支持将在未来的更新中得到改进。

Your Maven projects will work with all the major IDEs and command line, not just IntelliJ IDEA. 您的Maven项目将适用于所有主要的IDE和命令行,而不仅仅是IntelliJ IDEA。

@CrazyCoder is right using maven would be a better solution, but that conversation may just be a little bit too much to swallow. @CrazyCoder是正确使用maven会是一个更好的解决方案,但这个对话可能只是有点太多无法吞下去。

The .iml files are just xml and while it isn't documented it is pretty understandable. .iml文件只是xml,虽然没有记录,但这是可以理解的。 It shouldn't be the trickest thing to create a template and then use either ant property replacement or a custom task to generate these files for each module. 创建模板然后使用ant属性替换或自定义任务为每个模块生成这些文件不应该是最棘手的事情。

For reference you may want to look at the source for the maven-idea-plug it generates .iml files for a maven project and may provide you with a hint on how todo this with ant. 作为参考,您可能需要查看maven-idea-plug的源代码,它为maven项目生成.iml文件,并可能为您提供有关如何使用ant进行此操作的提示。 Note that @CrazyCoder points out the comments that this should only be a reference...don't use this for maven support in Idea. 请注意@CrazyCoder指出这应该只是一个引用的注释...不要在Idea中使用它作为maven支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM