Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use auto generated code in Maven project

Tags:

maven

We've a requirement where we need to auto generate the code and use it in another project. I'm using following code for autogenerating the code. But doing a "maven package" only generates sources and it doesn't give any errors in the log. Any help would be much 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>
like image 522
Prabhjot Avatar asked Nov 29 '25 03:11

Prabhjot


1 Answers

First i would suggest to generate the code in a different phase like generate-sources and next you have to tell the compiler plugin to compile that generated code as well. Take a look at the build-help-plugin for this purpose.

like image 154
khmarbaise Avatar answered Nov 30 '25 16:11

khmarbaise



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!