How to use automatically generated code in a Maven project

We have a requirement when we need to automatically generate code and use it in another project. I use the following code to auto-generate code. But the execution of the "maven package" only generates sources and does not give errors in the log. Any help would be greatly appreciated.

    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <id>exec-one</id>
                    <phase>compile</phase>
                    <configuration>
                        <mainClass>com.xx.yy.zzz.aa.bb.Autgen</mainClass>
                        <arguments>                             
                            <argument>-o</argument>
                            <argument>${srcOutputDir}/${packageDir}</argument>
                        </arguments>

                    </configuration>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin> 
    </plugins>
+3
source share
1 answer

First, I would suggest generating code in a different phase, for example, generate-sources , and then you should tell the compiler plug-in to compile this generated code. Take a look at the plug-in assembly for this purpose.

+1
source

All Articles