Question

I'm working on a project that's distributed as an IntelliJ plugin. Some of the required sources for the project are created by a code generation step prior to compiling the Java source files. These generated files are not placed in source control.

I have Ant tasks and a Maven plugin for this code generator that reliably integrates the code generation step into either of those two build systems.

How does IntelliJ support code generation during the build process for an IntelliJ Plugin project?

Was it helpful?

Solution

IntelliJ plugin deployment supports code generation indirectly :)

Each time your run Build > Prepare Plugin Module For Deployment, IntelliJ invokes "Make" command.

What you need to do is to mark Ant or Maven task as "Execute Before Make", then each time you run Make or Prepare Plugin For Deployment, the selected task will be executed.

enter image description here

How can I run the generate-sources phase? I don't see a way to include new phases under Lifecycle.

Your plugin should have generate-sources goal.

Sample 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>

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top