我正在开发一个作为 IntelliJ 插件分发的项目。该项目所需的一些源是在编译 Java 源文件之前通过代码生成步骤创建的。这些生成的文件不会放置在源代码管理中。
我有 Ant 任务和一个用于此代码生成器的 Maven 插件,可以将代码生成步骤可靠地集成到这两个构建系统中的任何一个中。
IntelliJ 如何在 IntelliJ 插件项目的构建过程中支持代码生成?
最佳答案
IntelliJ 插件部署间接支持代码生成:)
每次运行“构建”>“准备部署插件模块”时,IntelliJ 都会调用“Make”命令。
您需要做的是将Ant或Maven任务标记为“在Make之前执行”,然后每次运行Make或Prepare Plugin For Deployment时,都会执行所选任务。
block 引用>How can I run the generate-sources phase? I don't see a way to include new phases under Lifecycle.
你的插件应该有
generate-sources
目标。示例 POM
<project> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>eclipser</artifactId> <version>1</version> <build> <plugins> <plugin> <groupId>org.codehaus.modello</groupId> <artifactId>modello-maven-plugin</artifactId> <version>1.4</version> <executions> <execution> <configuration> <models> <model>src/main/mdo/maven.mdo</model> </models> <version>4.0.0</version> </configuration> <goals> <goal>java</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
关于java - 在 IntelliJ 插件构建期间运行代码生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21341652/